@@ -22,6 +22,7 @@ CREATE TABLE a (x1 int, x2 int, x3 int);
2222INSERT INTO a (x1, x2, x3) SELECT mod(ival,10), mod(ival,10), mod(ival,10) FROM generate_series(1,100) As ival;
2323CREATE TABLE b (y1 int, y2 int, y3 int);
2424INSERT INTO b (y1, y2, y3) SELECT mod(ival + 1,10), mod(ival + 1,10), mod(ival + 1,10) FROM generate_series(1,1000) As ival;
25+ ANALYZE a, b;
2526--
2627-- Returns string-by-string explain of a query. Made for removing some strings
2728-- from the explain output.
@@ -90,22 +91,22 @@ SELECT str AS result
9091FROM expln('
9192SELECT x1,y1 FROM A,B WHERE x1 < 5 AND x2 < 5 AND A.x1 = B.y1;') AS str
9293WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%' and str NOT LIKE '%Sort Method%';
93- result
94- -----------------------------------------------------------
94+ result
95+ -------------------------------------------------------------
9596 Hash Join (actual rows=5000 loops=1)
9697 AQO not used
9798 Output: a.x1, b.y1
98- Hash Cond: (b.y1 =a.x1 )
99- -> Seq Scan on public.b (actual rows=1000 loops=1)
99+ Hash Cond: (a.x1 =b.y1 )
100+ -> Seq Scan on public.a (actual rows=50 loops=1)
100101 AQO not used
101- Output: b.y1, b.y2, b.y3
102- -> Hash (actual rows=50 loops=1)
103- Output: a.x1
104- -> Seq Scan on public.a (actual rows=50 loops=1)
102+ Output: a.x1, a.x2, a.x3
103+ Filter: ((a.x1 < 5) AND (a.x2 < 5))
104+ Rows Removed by Filter: 50
105+ -> Hash (actual rows=1000 loops=1)
106+ Output: b.y1
107+ -> Seq Scan on public.b (actual rows=1000 loops=1)
105108 AQO not used
106- Output: a.x1
107- Filter: ((a.x1 < 5) AND (a.x2 < 5))
108- Rows Removed by Filter: 50
109+ Output: b.y1
109110 Using aqo: true
110111 AQO mode: LEARN
111112 JOINS: 1
@@ -191,22 +192,22 @@ SELECT str AS result
191192FROM expln('
192193SELECT x1,y1 FROM A,B WHERE x1 < 5 AND x2 < 5 AND x3 < 10 AND A.x1 = B.y1;') AS str
193194WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%' and str NOT LIKE '%Sort Method%';
194- result
195- -------------------------------------------------------------------
195+ result
196+ -------------------------------------------------------------
196197 Hash Join (actual rows=5000 loops=1)
197198 AQO not used
198199 Output: a.x1, b.y1
199- Hash Cond: (b.y1 =a.x1 )
200- -> Seq Scan on public.b (actual rows=1000 loops=1)
201- AQO: rows=1000, error=0%
202- Output:b.y1, b.y2, b.y3
203- -> Hash (actual rows=50 loops=1 )
204- Output: a.x1
205- ->Seq Scan on public.a (actual rows=50 loops=1)
206- AQO not used
207- Output: a.x1
208- Filter: ((a.x1 < 5) AND (a.x2 < 5) AND (a.x3 < 10))
209- Rows Removed by Filter: 50
200+ Hash Cond: (a.x1 =b.y1 )
201+ -> Seq Scan on public.a (actual rows=50 loops=1)
202+ AQO not used
203+ Output:a.x1, a.x2, a.x3
204+ Filter: ((a.x1 < 5) AND (a.x2 < 5) AND (a.x3 < 10) )
205+ Rows Removed by Filter: 50
206+ ->Hash (actual rows=1000 loops=1)
207+ Output: b.y1
208+ -> Seq Scan on public.b (actual rows=1000 loops=1)
209+ AQO: rows=1000, error=0%
210+ Output: b.y1
210211 Using aqo: true
211212 AQO mode: LEARN
212213 JOINS: 1
@@ -486,34 +487,35 @@ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%' and str NOT L
486487
487488CREATE TABLE c (z1 int, z2 int, z3 int);
488489INSERT INTO c (z1, z2, z3) SELECT mod(ival + 1,10), mod(ival + 1,10), mod(ival + 1,10) FROM generate_series(1,1000) As ival;
490+ ANALYZE c;
489491SELECT str AS result
490492FROM expln('
491493SELECT * FROM (a LEFT JOIN b ON a.x1 = b.y1) sc WHERE
492494not exists (SELECT z1 FROM c WHERE sc.x1=c.z1 );') AS str
493495WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%' and str NOT LIKE '%Sort Method%';
494- result
495- -------------------------------------------------------------------
496- HashLeft Join (actual rows=0 loops=1)
496+ result
497+ -------------------------------------------------------------------------
498+ HashRight Join (actual rows=0 loops=1)
497499 AQO not used
498500 Output: a.x1, a.x2, a.x3, b.y1, b.y2, b.y3
499- Hash Cond: (a.x1 = b.y1)
500- -> Hash Anti Join (actual rows=0 loops=1)
501- AQO not used
501+ Hash Cond: (b.y1 = a.x1)
502+ -> Seq Scan on public.b (never executed)
503+ AQO: rows=1000
504+ Output: b.y1, b.y2, b.y3
505+ -> Hash (actual rows=0 loops=1)
502506 Output: a.x1, a.x2, a.x3
503- Hash Cond: (a.x1 = c.z1)
504- -> Seq Scan on public.a (actual rows=100 loops=1)
507+ -> Hash Anti Join (actual rows=0 loops=1)
505508 AQO not used
506509 Output: a.x1, a.x2, a.x3
507- -> Hash (actual rows=1000 loops=1)
508- Output: c.z1
509- -> Seq Scan on public.c (actual rows=1000 loops=1)
510+ Hash Cond: (a.x1 = c.z1)
511+ -> Seq Scan on public.a (actual rows=100 loops=1)
510512 AQO not used
513+ Output: a.x1, a.x2, a.x3
514+ -> Hash (actual rows=1000 loops=1)
511515 Output: c.z1
512- -> Hash (never executed)
513- Output: b.y1, b.y2, b.y3
514- -> Seq Scan on public.b (never executed)
515- AQO: rows=1000
516- Output: b.y1, b.y2, b.y3
516+ -> Seq Scan on public.c (actual rows=1000 loops=1)
517+ AQO not used
518+ Output: c.z1
517519 Using aqo: true
518520 AQO mode: LEARN
519521 JOINS: 2