@@ -22,6 +22,7 @@ CREATE TABLE a (x1 int, x2 int, x3 int);
22
22
INSERT INTO a (x1, x2, x3) SELECT mod(ival,10), mod(ival,10), mod(ival,10) FROM generate_series(1,100) As ival;
23
23
CREATE TABLE b (y1 int, y2 int, y3 int);
24
24
INSERT 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;
25
26
--
26
27
-- Returns string-by-string explain of a query. Made for removing some strings
27
28
-- from the explain output.
@@ -90,22 +91,22 @@ SELECT str AS result
90
91
FROM expln('
91
92
SELECT x1,y1 FROM A,B WHERE x1 < 5 AND x2 < 5 AND A.x1 = B.y1;') AS str
92
93
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%' and str NOT LIKE '%Sort Method%';
93
- result
94
- -----------------------------------------------------------
94
+ result
95
+ -------------------------------------------------------------
95
96
Hash Join (actual rows=5000 loops=1)
96
97
AQO not used
97
98
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)
100
101
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)
105
108
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
109
110
Using aqo: true
110
111
AQO mode: LEARN
111
112
JOINS: 1
@@ -191,22 +192,22 @@ SELECT str AS result
191
192
FROM expln('
192
193
SELECT x1,y1 FROM A,B WHERE x1 < 5 AND x2 < 5 AND x3 < 10 AND A.x1 = B.y1;') AS str
193
194
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%' and str NOT LIKE '%Sort Method%';
194
- result
195
- -------------------------------------------------------------------
195
+ result
196
+ -------------------------------------------------------------
196
197
Hash Join (actual rows=5000 loops=1)
197
198
AQO not used
198
199
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
210
211
Using aqo: true
211
212
AQO mode: LEARN
212
213
JOINS: 1
@@ -486,34 +487,35 @@ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%' and str NOT L
486
487
487
488
CREATE TABLE c (z1 int, z2 int, z3 int);
488
489
INSERT 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;
489
491
SELECT str AS result
490
492
FROM expln('
491
493
SELECT * FROM (a LEFT JOIN b ON a.x1 = b.y1) sc WHERE
492
494
not exists (SELECT z1 FROM c WHERE sc.x1=c.z1 );') AS str
493
495
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%' and str NOT LIKE '%Sort Method%';
494
- result
495
- -------------------------------------------------------------------
496
- Hash Left Join (actual rows=0 loops=1)
496
+ result
497
+ -------------------------------------------------------------------------
498
+ Hash Right Join (actual rows=0 loops=1)
497
499
AQO not used
498
500
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)
502
506
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)
505
508
AQO not used
506
509
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)
510
512
AQO not used
513
+ Output: a.x1, a.x2, a.x3
514
+ -> Hash (actual rows=1000 loops=1)
511
515
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
517
519
Using aqo: true
518
520
AQO mode: LEARN
519
521
JOINS: 2
0 commit comments