Skip to content

Disable materializing strategy of the planner in look-a-like tests. #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 39 additions & 41 deletions expected/look_a_like.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;
SET aqo.mode = 'learn';
SET aqo.show_details = 'on';
SET enable_material = 'off';
DROP TABLE IF EXISTS a,b CASCADE;
NOTICE: table "a" does not exist, skipping
NOTICE: table "b" does not exist, skipping
Expand Down Expand Up @@ -38,65 +39,60 @@ WHERE str NOT LIKE 'Query Identifier%';
JOINS: 0
(8 rows)

-- cardinality 100 in the first Seq Scan on a
SELECT str AS result
FROM expln('
SELECT x FROM A,B WHERE x = 5 AND A.x = B.y;') AS str
WHERE str NOT LIKE 'Query Identifier%';
result
------------------------------------------------------------
WHERE str NOT LIKE 'Query Identifier%'
; -- Find cardinality for SCAN A(x=5) from a neighbour class, created by the
result
--------------------------------------------------------
Nested Loop (actual rows=10000 loops=1)
AQO not used
Output: a.x
-> Seq Scan on public.a (actual rows=100 loops=1)
-> Seq Scan on public.b (actual rows=100 loops=1)
AQO not used
Output: b.y
Filter: (b.y = 5)
Rows Removed by Filter: 900
-> Seq Scan on public.a (actual rows=100 loops=100)
AQO: rows=100, error=0%
Output: a.x
Filter: (a.x = 5)
Rows Removed by Filter: 900
-> Materialize (actual rows=100 loops=100)
AQO not used
Output: b.y
-> Seq Scan on public.b (actual rows=100 loops=1)
AQO not used
Output: b.y
Filter: (b.y = 5)
Rows Removed by Filter: 900
Using aqo: true
AQO mode: LEARN
JOINS: 0
(19 rows)
(16 rows)

-- cardinality 100 in Nesteed Loop in the first Seq Scan on a
-- query, executed above.
SELECT str AS result
FROM expln('
SELECT x, sum(x) FROM A,B WHERE y = 5 AND A.x = B.y group by(x);') AS str
WHERE str NOT LIKE 'Query Identifier%';
result
------------------------------------------------------------------
WHERE str NOT LIKE 'Query Identifier%'
; -- Find the JOIN cardinality from a neighbour class.
result
--------------------------------------------------------------
GroupAggregate (actual rows=1 loops=1)
AQO not used
Output: a.x, sum(a.x)
Group Key: a.x
-> Nested Loop (actual rows=10000 loops=1)
AQO not used
AQO: rows=10000, error=0%
Output: a.x
-> Seq Scan on public.a (actual rows=100 loops=1)
AQO: rows=100, error=0%
Output: a.x
Filter: (a.x = 5)
Rows Removed by Filter: 900
-> Materialize (actual rows=100 loops=100)
-> Seq Scan on public.b (actual rows=100 loops=100)
AQO: rows=100, error=0%
Output: b.y
-> Seq Scan on public.b (actual rows=100 loops=1)
AQO: rows=100, error=0%
Output: b.y
Filter: (b.y = 5)
Rows Removed by Filter: 900
Filter: (b.y = 5)
Rows Removed by Filter: 900
Using aqo: true
AQO mode: LEARN
JOINS: 1
(23 rows)
(20 rows)

-- cardinality 100 in the first Seq Scan on a
SELECT str AS result
Expand Down Expand Up @@ -176,37 +172,38 @@ SELECT str AS result
FROM expln('
SELECT x FROM A,B where x < 10 and y > 10 group by(x);') AS str
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
result
----------------------------------------------------------------
result
----------------------------------------------------------
HashAggregate (actual rows=0 loops=1)
AQO not used
Output: a.x
Group Key: a.x
-> Nested Loop (actual rows=0 loops=1)
AQO not used
Output: a.x
-> Seq Scan on public.a (actual rows=1000 loops=1)
AQO: rows=1000, error=0%
-> Seq Scan on public.b (actual rows=0 loops=1)
AQO not used
Output: b.y
Filter: (b.y > 10)
Rows Removed by Filter: 1000
-> Seq Scan on public.a (never executed)
AQO: rows=1000
Output: a.x
Filter: (a.x < 10)
-> Materialize (actual rows=0 loops=1000)
AQO not used
-> Seq Scan on public.b (actual rows=0 loops=1)
AQO not used
Filter: (b.y > 10)
Rows Removed by Filter: 1000
Using aqo: true
AQO mode: LEARN
JOINS: 1
(20 rows)
(19 rows)

-- cardinality 1000 Hash Cond: (a.x = b.y) and 1 Seq Scan on b
-- this cardinality is wrong because we take it from bad neibours (previous query).
-- clause y > 10 give count of rows with the same clauses.
--
-- TODO:
-- Not executed case. What could we do better here?
--
SELECT str AS result
FROM expln('
SELECT x,y FROM A,B WHERE x < 10 and y > 10 AND A.x = B.y;') AS str
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%'
;
result
----------------------------------------------------------
Hash Join (actual rows=0 loops=1)
Expand All @@ -230,6 +227,7 @@ WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
JOINS: 0
(19 rows)

RESET enable_material;
DROP TABLE a,b CASCADE;
SELECT true FROM aqo_reset();
?column?
Expand Down
28 changes: 19 additions & 9 deletions sql/look_a_like.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ SET aqo.join_threshold = 0;
SET aqo.mode = 'learn';
SET aqo.show_details = 'on';

SET enable_material = 'off';

DROP TABLE IF EXISTS a,b CASCADE;
CREATE TABLE a (x int);
INSERT INTO a (x) SELECT mod(ival,10) FROM generate_series(1,1000) As ival;
Expand All @@ -28,16 +30,20 @@ SELECT str AS result
FROM expln('
SELECT x FROM A where x = 5;') AS str
WHERE str NOT LIKE 'Query Identifier%';
-- cardinality 100 in the first Seq Scan on a

SELECT str AS result
FROM expln('
SELECT x FROM A,B WHERE x = 5 AND A.x = B.y;') AS str
WHERE str NOT LIKE 'Query Identifier%';
-- cardinality 100 in Nesteed Loop in the first Seq Scan on a
WHERE str NOT LIKE 'Query Identifier%'
; -- Find cardinality for SCAN A(x=5) from a neighbour class, created by the
-- query, executed above.

SELECT str AS result
FROM expln('
SELECT x, sum(x) FROM A,B WHERE y = 5 AND A.x = B.y group by(x);') AS str
WHERE str NOT LIKE 'Query Identifier%';
WHERE str NOT LIKE 'Query Identifier%'
; -- Find the JOIN cardinality from a neighbour class.

-- cardinality 100 in the first Seq Scan on a
SELECT str AS result
FROM expln('
Expand All @@ -61,14 +67,18 @@ SELECT str AS result
FROM expln('
SELECT x FROM A,B where x < 10 and y > 10 group by(x);') AS str
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
-- cardinality 1000 Hash Cond: (a.x = b.y) and 1 Seq Scan on b
-- this cardinality is wrong because we take it from bad neibours (previous query).
-- clause y > 10 give count of rows with the same clauses.

--
-- TODO:
-- Not executed case. What could we do better here?
--
SELECT str AS result
FROM expln('
SELECT x,y FROM A,B WHERE x < 10 and y > 10 AND A.x = B.y;') AS str
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%';
WHERE str NOT LIKE 'Query Identifier%' and str NOT LIKE '%Memory%'
;

RESET enable_material;
DROP TABLE a,b CASCADE;
SELECT true FROM aqo_reset();
DROP EXTENSION aqo CASCADE;
DROP EXTENSION aqo CASCADE;