Skip to content

Commit 599fff9

Browse files
Alena Rybakinadanolivo
Alena Rybakina
authored andcommitted
Fix feature_subspace output test.
Delete platform dependent lines containing Memory and add order by command in feature_subspace test for statical result.
1 parent fe228ac commit 599fff9

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

‎expected/feature_subspace.out

+25-13
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,68 @@ SET aqo.show_details = 'on';
66
CREATE TABLE a AS (SELECT gs AS x FROM generate_series(1,10) AS gs);
77
CREATE TABLE b AS (SELECT gs AS x FROM generate_series(1,100) AS gs);
88
--
9+
-- Returns string-by-string explain of a query. Made for removing some strings
10+
-- from the explain output.
11+
--
12+
CREATE OR REPLACE FUNCTION expln(query_string text) RETURNS SETOF text AS $$
13+
BEGIN
14+
RETURN QUERY
15+
EXECUTE format('EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF) %s', query_string);
16+
RETURN;
17+
END;
18+
$$ LANGUAGE PLPGSQL;
19+
--
920
-- A LEFT JOIN B isn't equal B LEFT JOIN A.
1021
--
11-
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
12-
SELECT * FROM a LEFT JOIN b USING (x);
13-
QUERY PLAN
22+
SELECT str AS result
23+
FROM expln('
24+
SELECT * FROM a LEFT JOIN b USING (x);') AS str
25+
WHERE str NOT LIKE '%Memory%';
26+
result
1427
-----------------------------------------------------
1528
Merge Left Join (actual rows=10 loops=1)
1629
AQO not used
1730
Merge Cond: (a.x = b.x)
1831
-> Sort (actual rows=10 loops=1)
1932
AQO not used
2033
Sort Key: a.x
21-
Sort Method: quicksort Memory: 25kB
2234
-> Seq Scan on a (actual rows=10 loops=1)
2335
AQO not used
2436
-> Sort (actual rows=11 loops=1)
2537
AQO not used
2638
Sort Key: b.x
27-
Sort Method: quicksort Memory: 30kB
2839
-> Seq Scan on b (actual rows=100 loops=1)
2940
AQO not used
3041
Using aqo: true
3142
AQO mode: LEARN
3243
JOINS: 0
33-
(18 rows)
44+
(16 rows)
3445

3546
-- TODO: Using method of other classes neigurs we get a bad estimation.
36-
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
37-
SELECT * FROM b LEFT JOIN a USING (x);
38-
QUERY PLAN
39-
------------------------------------------------------
47+
SELECT str AS result
48+
FROM expln('
49+
SELECT * FROM b LEFT JOIN a USING (x);') AS str
50+
WHERE str NOT LIKE '%Memory%';
51+
result
52+
----------------------------------------------------
4053
Hash Left Join (actual rows=100 loops=1)
4154
AQO: rows=10, error=-900%
4255
Hash Cond: (b.x = a.x)
4356
-> Seq Scan on b (actual rows=100 loops=1)
4457
AQO: rows=100, error=0%
4558
-> Hash (actual rows=10 loops=1)
4659
AQO not used
47-
Buckets: 1024 Batches: 1 Memory Usage: 9kB
4860
-> Seq Scan on a (actual rows=10 loops=1)
4961
AQO: rows=10, error=0%
5062
Using aqo: true
5163
AQO mode: LEARN
5264
JOINS: 0
53-
(13 rows)
65+
(12 rows)
5466

5567
-- Look into the reason: two JOINs from different classes have the same FSS.
5668
SELECT to_char(d1.targets[1], 'FM999.00') AS target FROM aqo_data d1
5769
JOIN aqo_data d2 ON (d1.fs <> d2.fs AND d1.fss = d2.fss)
58-
WHERE 'a'::regclass = ANY (d1.oids) AND 'b'::regclass = ANY (d1.oids);
70+
WHERE 'a'::regclass = ANY (d1.oids) AND 'b'::regclass = ANY (d1.oids) order by target;
5971
target
6072
--------
6173
2.30

‎sql/feature_subspace.sql

+21-6
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,35 @@ CREATE TABLE a AS (SELECT gs AS x FROM generate_series(1,10) AS gs);
1010
CREATE TABLE b AS (SELECT gs AS x FROM generate_series(1,100) AS gs);
1111

1212
--
13-
-- A LEFT JOIN B isn't equal B LEFT JOIN A.
13+
-- Returns string-by-string explain of a query. Made for removing some strings
14+
-- from the explain output.
1415
--
16+
CREATE OR REPLACE FUNCTION expln(query_string text) RETURNS SETOF text AS $$
17+
BEGIN
18+
RETURN QUERY
19+
EXECUTE format('EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF) %s', query_string);
20+
RETURN;
21+
END;
22+
$$ LANGUAGE PLPGSQL;
1523

16-
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
17-
SELECT * FROM a LEFT JOIN b USING (x);
24+
--
25+
-- A LEFT JOIN B isn't equal B LEFT JOIN A.
26+
--
27+
SELECT str AS result
28+
FROM expln('
29+
SELECT * FROM a LEFT JOIN b USING (x);') AS str
30+
WHERE str NOT LIKE '%Memory%';
1831

1932
-- TODO: Using method of other classes neigurs we get a bad estimation.
20-
EXPLAIN (ANALYZE, COSTS OFF, TIMING OFF, SUMMARY OFF)
21-
SELECT * FROM b LEFT JOIN a USING (x);
33+
SELECT str AS result
34+
FROM expln('
35+
SELECT * FROM b LEFT JOIN a USING (x);') AS str
36+
WHERE str NOT LIKE '%Memory%';
2237

2338
-- Look into the reason: two JOINs from different classes have the same FSS.
2439
SELECT to_char(d1.targets[1], 'FM999.00') AS target FROM aqo_data d1
2540
JOIN aqo_data d2 ON (d1.fs <> d2.fs AND d1.fss = d2.fss)
26-
WHERE 'a'::regclass = ANY (d1.oids) AND 'b'::regclass = ANY (d1.oids);
41+
WHERE 'a'::regclass = ANY (d1.oids) AND 'b'::regclass = ANY (d1.oids) order by target;
2742

2843
DROP TABLE a,b CASCADE;
2944
SELECT true FROM aqo_reset();

0 commit comments

Comments
 (0)