@@ -2,6 +2,7 @@ CREATE EXTENSION aqo;
2
2
SET aqo.join_threshold = 0;
3
3
SET aqo.mode = 'learn';
4
4
SET aqo.show_details = 'on';
5
+ SET enable_material = 'off';
5
6
DROP TABLE IF EXISTS a,b CASCADE;
6
7
NOTICE: table "a" does not exist, skipping
7
8
NOTICE: table "b" does not exist, skipping
@@ -38,65 +39,60 @@ WHERE str NOT LIKE 'Query Identifier%';
38
39
JOINS: 0
39
40
(8 rows)
40
41
41
- -- cardinality 100 in the first Seq Scan on a
42
42
SELECT str AS result
43
43
FROM expln('
44
44
SELECT x FROM A,B WHERE x = 5 AND A.x = B.y;') AS str
45
- WHERE str NOT LIKE 'Query Identifier%';
46
- result
47
- ------------------------------------------------------------
45
+ WHERE str NOT LIKE 'Query Identifier%'
46
+ ; -- Find cardinality for SCAN A(x=5) from a neigur class, created by the
47
+ result
48
+ --------------------------------------------------------
48
49
Nested Loop (actual rows=10000 loops=1)
49
50
AQO not used
50
51
Output: a.x
51
- -> Seq Scan on public.a (actual rows=100 loops=1)
52
+ -> Seq Scan on public.b (actual rows=100 loops=1)
53
+ AQO not used
54
+ Output: b.y
55
+ Filter: (b.y = 5)
56
+ Rows Removed by Filter: 900
57
+ -> Seq Scan on public.a (actual rows=100 loops=100)
52
58
AQO: rows=100, error=0%
53
59
Output: a.x
54
60
Filter: (a.x = 5)
55
61
Rows Removed by Filter: 900
56
- -> Materialize (actual rows=100 loops=100)
57
- AQO not used
58
- Output: b.y
59
- -> Seq Scan on public.b (actual rows=100 loops=1)
60
- AQO not used
61
- Output: b.y
62
- Filter: (b.y = 5)
63
- Rows Removed by Filter: 900
64
62
Using aqo: true
65
63
AQO mode: LEARN
66
64
JOINS: 0
67
- (19 rows)
65
+ (16 rows)
68
66
69
- -- cardinality 100 in Nesteed Loop in the first Seq Scan on a
67
+ -- query, executed above.
70
68
SELECT str AS result
71
69
FROM expln('
72
70
SELECT x, sum(x) FROM A,B WHERE y = 5 AND A.x = B.y group by(x);') AS str
73
- WHERE str NOT LIKE 'Query Identifier%';
74
- result
75
- ------------------------------------------------------------------
71
+ WHERE str NOT LIKE 'Query Identifier%'
72
+ ; -- Find the JOIN cardinality from a neigur class.
73
+ result
74
+ --------------------------------------------------------------
76
75
GroupAggregate (actual rows=1 loops=1)
77
76
AQO not used
78
77
Output: a.x, sum(a.x)
79
78
Group Key: a.x
80
79
-> Nested Loop (actual rows=10000 loops=1)
81
- AQO not used
80
+ AQO: rows=10000, error=0%
82
81
Output: a.x
83
82
-> Seq Scan on public.a (actual rows=100 loops=1)
84
83
AQO: rows=100, error=0%
85
84
Output: a.x
86
85
Filter: (a.x = 5)
87
86
Rows Removed by Filter: 900
88
- -> Materialize (actual rows=100 loops=100)
87
+ -> Seq Scan on public.b (actual rows=100 loops=100)
89
88
AQO: rows=100, error=0%
90
89
Output: b.y
91
- -> Seq Scan on public.b (actual rows=100 loops=1)
92
- AQO: rows=100, error=0%
93
- Output: b.y
94
- Filter: (b.y = 5)
95
- Rows Removed by Filter: 900
90
+ Filter: (b.y = 5)
91
+ Rows Removed by Filter: 900
96
92
Using aqo: true
97
93
AQO mode: LEARN
98
94
JOINS: 1
99
- (23 rows)
95
+ (20 rows)
100
96
101
97
-- cardinality 100 in the first Seq Scan on a
102
98
SELECT str AS result
@@ -176,37 +172,38 @@ SELECT str AS result
176
172
FROM expln('
177
173
SELECT x FROM A,B where x < 10 and y > 10 group by(x);') AS str
178
174
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
179
- result
180
- ----------------------------------------------------------------
175
+ result
176
+ ----------------------------------------------------------
181
177
HashAggregate (actual rows=0 loops=1)
182
178
AQO not used
183
179
Output: a.x
184
180
Group Key: a.x
185
181
-> Nested Loop (actual rows=0 loops=1)
186
182
AQO not used
187
183
Output: a.x
188
- -> Seq Scan on public.a (actual rows=1000 loops=1)
189
- AQO: rows=1000, error=0%
184
+ -> Seq Scan on public.b (actual rows=0 loops=1)
185
+ AQO not used
186
+ Output: b.y
187
+ Filter: (b.y > 10)
188
+ Rows Removed by Filter: 1000
189
+ -> Seq Scan on public.a (never executed)
190
+ AQO: rows=1000
190
191
Output: a.x
191
192
Filter: (a.x < 10)
192
- -> Materialize (actual rows=0 loops=1000)
193
- AQO not used
194
- -> Seq Scan on public.b (actual rows=0 loops=1)
195
- AQO not used
196
- Filter: (b.y > 10)
197
- Rows Removed by Filter: 1000
198
193
Using aqo: true
199
194
AQO mode: LEARN
200
195
JOINS: 1
201
- (20 rows)
196
+ (19 rows)
202
197
203
- -- cardinality 1000 Hash Cond: (a.x = b.y) and 1 Seq Scan on b
204
- -- this cardinality is wrong because we take it from bad neibours (previous query).
205
- -- clause y > 10 give count of rows with the same clauses.
198
+ --
199
+ -- TODO:
200
+ -- Not executed case. What could we do better here?
201
+ --
206
202
SELECT str AS result
207
203
FROM expln('
208
204
SELECT x,y FROM A,B WHERE x < 10 and y > 10 AND A.x = B.y;') AS str
209
- WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
205
+ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%'
206
+ ;
210
207
result
211
208
----------------------------------------------------------
212
209
Hash Join (actual rows=0 loops=1)
@@ -230,6 +227,7 @@ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
230
227
JOINS: 0
231
228
(19 rows)
232
229
230
+ RESET enable_material;
233
231
DROP TABLE a,b CASCADE;
234
232
SELECT true FROM aqo_reset();
235
233
?column?
0 commit comments