Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
CREATE TABLE a(x int, t int); CREATE TABLE b(x int, t int); INSERT INTO a SELECT x, random(1,100) FROM generate_series(1,10000) g(x); INSERT INTO b SELECT x, random(1,100) FROM generate_series(1,10000) g(x); CREATE INDEX ON a(x); CREATE INDEX ON b(x); SET enable_hashjoin = off; SET enable_mergejoin = off; SET enable_seqscan = off; ANALYZE; EXPLAIN ANALYZE SELECT a.t at, (SELECT t FROM b WHERE b.x = a.x) bt FROM a; EXPLAIN ANALYZE SELECT a.t at, b.t bt FROM a JOIN b ON b.x = a.x;

Stuck with a problem? Got Error? Ask AI support!

Copy Clear