@@ -2,6 +2,7 @@ CREATE EXTENSION aqo;
22SET aqo.join_threshold = 0;
33SET aqo.mode = 'learn';
44SET aqo.show_details = 'on';
5+ SET enable_material = 'off';
56DROP TABLE IF EXISTS a,b CASCADE;
67NOTICE: table "a" does not exist, skipping
78NOTICE: table "b" does not exist, skipping
@@ -38,65 +39,60 @@ WHERE str NOT LIKE 'Query Identifier%';
3839 JOINS: 0
3940(8 rows)
4041
41- -- cardinality 100 in the first Seq Scan on a
4242SELECT str AS result
4343FROM expln('
4444SELECT 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 neighbour class, created by the
47+ result
48+ --------------------------------------------------------
4849 Nested Loop (actual rows=10000 loops=1)
4950 AQO not used
5051 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)
5258 AQO: rows=100, error=0%
5359 Output: a.x
5460 Filter: (a.x = 5)
5561 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
6462 Using aqo: true
6563 AQO mode: LEARN
6664 JOINS: 0
67- (19 rows)
65+ (16 rows)
6866
69- --cardinality 100 in Nesteed Loop in the first Seq Scan on a
67+ --query, executed above.
7068SELECT str AS result
7169FROM expln('
7270SELECT 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 neighbour class.
73+ result
74+ --------------------------------------------------------------
7675 GroupAggregate (actual rows=1 loops=1)
7776 AQO not used
7877 Output: a.x, sum(a.x)
7978 Group Key: a.x
8079 -> Nested Loop (actual rows=10000 loops=1)
81- AQO not used
80+ AQO: rows=10000, error=0%
8281 Output: a.x
8382 -> Seq Scan on public.a (actual rows=100 loops=1)
8483 AQO: rows=100, error=0%
8584 Output: a.x
8685 Filter: (a.x = 5)
8786 Rows Removed by Filter: 900
88- ->Materialize (actual rows=100 loops=100)
87+ ->Seq Scan on public.b (actual rows=100 loops=100)
8988 AQO: rows=100, error=0%
9089 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
9692 Using aqo: true
9793 AQO mode: LEARN
9894 JOINS: 1
99- (23 rows)
95+ (20 rows)
10096
10197-- cardinality 100 in the first Seq Scan on a
10298SELECT str AS result
@@ -176,37 +172,38 @@ SELECT str AS result
176172FROM expln('
177173SELECT x FROM A,B where x < 10 and y > 10 group by(x);') AS str
178174WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
179- result
180- ----------------------------------------------------------------
175+ result
176+ ----------------------------------------------------------
181177 HashAggregate (actual rows=0 loops=1)
182178 AQO not used
183179 Output: a.x
184180 Group Key: a.x
185181 -> Nested Loop (actual rows=0 loops=1)
186182 AQO not used
187183 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
190191 Output: a.x
191192 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
198193 Using aqo: true
199194 AQO mode: LEARN
200195 JOINS: 1
201- (20 rows)
196+ (19 rows)
202197
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+ --
206202SELECT str AS result
207203FROM expln('
208204SELECT 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+ ;
210207 result
211208----------------------------------------------------------
212209 Hash Join (actual rows=0 loops=1)
@@ -230,6 +227,7 @@ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
230227 JOINS: 0
231228(19 rows)
232229
230+ RESET enable_material;
233231DROP TABLE a,b CASCADE;
234232SELECT true FROM aqo_reset();
235233 ?column?