Skip to content

One more step to improve AQO regression tests stability. #121

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

Merged
merged 1 commit into from
Feb 14, 2023
Merged
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
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ TAP_TESTS = 1
REGRESS = aqo_dummy_test
REGRESS_OPTS = --schedule=$(srcdir)/regress_schedule

# Set default values of some gucs to be stable on custom settings during
# a kind of installcheck
PGOPTIONS = --aqo.force_collect_stat=off --max_parallel_maintenance_workers=1 \
--aqo.join_threshold=0 --max_parallel_workers_per_gather=1
export PGOPTIONS

fdw_srcdir = $(top_srcdir)/contrib/postgres_fdw
stat_srcdir = $(top_srcdir)/contrib/pg_stat_statements
PG_CPPFLAGS += -I$(libpq_srcdir) -I$(fdw_srcdir) -I$(stat_srcdir)
Expand Down
3 changes: 0 additions & 3 deletions aqo.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
autovacuum = off
shared_preload_libraries = 'postgres_fdw, aqo'
max_parallel_maintenance_workers = 1 # switch off parallel workers because of unsteadiness
aqo.wide_search = 'on'

21 changes: 10 additions & 11 deletions expected/aqo_controlled.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
CREATE EXTENSION IF NOT EXISTS aqo;
SELECT true AS success FROM aqo_reset();
success
---------
t
(1 row)

CREATE TABLE aqo_test0(a int, b int, c int, d int);
WITH RECURSIVE t(a, b, c, d)
AS (
Expand Down Expand Up @@ -25,8 +32,6 @@ AS (
) INSERT INTO aqo_test2 (SELECT * FROM t);
CREATE INDEX aqo_test2_idx_a ON aqo_test2 (a);
ANALYZE aqo_test2;
CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;
SET aqo.mode = 'controlled';
EXPLAIN (COSTS FALSE)
SELECT * FROM aqo_test0
Expand Down Expand Up @@ -199,11 +204,12 @@ WHERE t1.a = t2.b AND t2.a = t3.b;

SELECT count(*) FROM
(SELECT queryid AS id FROM aqo_queries) AS q1,
LATERAL aqo_queries_update(q1.id, NULL, NULL, true, NULL)
LATERAL aqo_queries_update(q1.id, NULL, NULL, true, NULL) AS ret
WHERE NOT ret
; -- set use = true
count
-------
12
1
(1 row)

EXPLAIN (COSTS FALSE)
Expand Down Expand Up @@ -311,11 +317,4 @@ DROP INDEX aqo_test1_idx_a;
DROP TABLE aqo_test1;
DROP INDEX aqo_test2_idx_a;
DROP TABLE aqo_test2;
-- XXX: extension dropping doesn't clear file storage. Do it manually.
SELECT 1 FROM aqo_reset();
?column?
----------
1
(1 row)

DROP EXTENSION aqo;
25 changes: 13 additions & 12 deletions expected/aqo_disabled.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-- Create the extension. Drop all lumps which could survive from
-- previous pass (repeated installcheck as an example).
CREATE EXTENSION IF NOT EXISTS aqo;
SELECT true AS success FROM aqo_reset();
success
---------
t
(1 row)

CREATE TABLE aqo_test0(a int, b int, c int, d int);
WITH RECURSIVE t(a, b, c, d)
AS (
Expand All @@ -16,8 +25,6 @@ AS (
) INSERT INTO aqo_test1 (SELECT * FROM t);
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
ANALYZE aqo_test1;
CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;
SET aqo.mode = 'controlled';
CREATE TABLE tmp1 AS SELECT * FROM aqo_test0
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
Expand Down Expand Up @@ -151,11 +158,12 @@ SELECT count(*) FROM aqo_queries WHERE queryid <> fs; -- Should be zero
SET aqo.mode = 'controlled';
SELECT count(*) FROM
(SELECT queryid AS id FROM aqo_queries) AS q1,
LATERAL aqo_queries_update(q1.id, NULL, true, true, false)
LATERAL aqo_queries_update(q1.id, NULL, true, true, false) AS ret
WHERE NOT ret
; -- Enable all disabled query classes
count
-------
5
1
(1 row)

EXPLAIN SELECT * FROM aqo_test0
Expand Down Expand Up @@ -223,15 +231,8 @@ SELECT count(*) FROM aqo_queries WHERE queryid <> fs; -- Should be zero
0
(1 row)

-- XXX: extension dropping doesn't clear file storage. Do it manually.
SELECT 1 FROM aqo_reset();
?column?
----------
1
(1 row)

DROP EXTENSION aqo;
DROP INDEX aqo_test0_idx_a;
DROP TABLE aqo_test0;
DROP INDEX aqo_test1_idx_a;
DROP TABLE aqo_test1;
DROP EXTENSION aqo;
29 changes: 21 additions & 8 deletions expected/aqo_fdw.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
-- JOIN push-down (check push of baserestrictinfo and joininfo)
-- Aggregate push-down
-- Push-down of groupings with HAVING clause.
CREATE EXTENSION aqo;
CREATE EXTENSION postgres_fdw;
CREATE EXTENSION IF NOT EXISTS aqo;
CREATE EXTENSION IF NOT EXISTS postgres_fdw;
SELECT true AS success FROM aqo_reset();
success
---------
t
(1 row)

SET aqo.mode = 'learn';
SET aqo.show_details = 'true'; -- show AQO info for each node and entire query.
SET aqo.show_hash = 'false'; -- a hash value is system-depended. Ignore it.
SET aqo.join_threshold = 0;
DO $d$
BEGIN
EXECUTE $$CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw
Expand Down Expand Up @@ -100,15 +105,23 @@ SELECT str FROM expln('
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
SELECT * FROM frgn AS a, frgn AS b WHERE a.x=b.x;
') AS str WHERE str NOT LIKE '%Sort Method%';
str
-------------------------------------------
Foreign Scan (actual rows=1 loops=1)
str
------------------------------------------------------------
Merge Join (actual rows=1 loops=1)
AQO not used
Relations: (frgn a) INNER JOIN (frgn b)
Merge Cond: (a.x = b.x)
-> Sort (actual rows=1 loops=1)
Sort Key: a.x
-> Foreign Scan on frgn a (actual rows=1 loops=1)
AQO not used
-> Sort (actual rows=1 loops=1)
Sort Key: b.x
-> Foreign Scan on frgn b (actual rows=1 loops=1)
AQO not used
Using aqo: true
AQO mode: LEARN
JOINS: 0
(6 rows)
(14 rows)

-- Should learn on postgres_fdw nodes
SELECT str FROM expln('
Expand Down
17 changes: 8 additions & 9 deletions expected/aqo_forced.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
-- Preliminaries
CREATE EXTENSION IF NOT EXISTS aqo;
SELECT true AS success FROM aqo_reset();
success
---------
t
(1 row)

CREATE TABLE aqo_test0(a int, b int, c int, d int);
WITH RECURSIVE t(a, b, c, d)
AS (
Expand All @@ -16,8 +24,6 @@ AS (
) INSERT INTO aqo_test1 (SELECT * FROM t);
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
ANALYZE aqo_test1;
CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;
SET aqo.mode = 'controlled';
EXPLAIN (COSTS FALSE)
SELECT * FROM aqo_test0
Expand Down Expand Up @@ -82,11 +88,4 @@ DROP INDEX aqo_test0_idx_a;
DROP TABLE aqo_test0;
DROP INDEX aqo_test1_idx_a;
DROP TABLE aqo_test1;
-- XXX: extension dropping doesn't clear file storage. Do it manually.
SELECT 1 FROM aqo_reset();
?column?
----------
1
(1 row)

DROP EXTENSION aqo;
16 changes: 7 additions & 9 deletions expected/aqo_intelligent.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
CREATE EXTENSION IF NOT EXISTS aqo;
SELECT true AS success FROM aqo_reset();
success
---------
t
(1 row)

CREATE TABLE aqo_test0(a int, b int, c int, d int);
WITH RECURSIVE t(a, b, c, d)
AS (
Expand All @@ -16,8 +23,6 @@ AS (
) INSERT INTO aqo_test1 (SELECT * FROM t);
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
ANALYZE aqo_test1;
CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;
SET aqo.mode = 'intelligent';
EXPLAIN SELECT * FROM aqo_test0
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
Expand Down Expand Up @@ -519,11 +524,4 @@ DROP INDEX aqo_test0_idx_a;
DROP TABLE aqo_test0;
DROP INDEX aqo_test1_idx_a;
DROP TABLE aqo_test1;
-- XXX: extension dropping doesn't clear file storage. Do it manually.
SELECT 1 FROM aqo_reset();
?column?
----------
1
(1 row)

DROP EXTENSION aqo;
26 changes: 12 additions & 14 deletions expected/aqo_learn.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
CREATE EXTENSION IF NOT EXISTS aqo;
SELECT true AS success FROM aqo_reset();
success
---------
t
(1 row)

-- The function just copied from stats_ext.sql
create function check_estimated_rows(text) returns table (estimated int, actual int)
language plpgsql as
Expand Down Expand Up @@ -36,8 +43,6 @@ AS (
) INSERT INTO aqo_test1 (SELECT * FROM t);
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
ANALYZE aqo_test1;
CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;
SET aqo.mode = 'intelligent';
EXPLAIN SELECT * FROM aqo_test0
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;
Expand Down Expand Up @@ -236,10 +241,10 @@ SELECT count(*) FROM tmp1;
(1 row)

-- Remove data on some unneeded instances of tmp1 table.
SELECT * FROM aqo_cleanup();
nfs | nfss
-----+------
9 | 18
SELECT true AS success FROM aqo_cleanup();
success
---------
t
(1 row)

-- Result of the query below should be empty
Expand Down Expand Up @@ -563,7 +568,7 @@ SELECT * FROM check_estimated_rows(
'SELECT * FROM aqo_test1 AS t1, aqo_test1 AS t2 WHERE t1.a = t2.b');
estimated | actual
-----------+--------
19 | 19
20 | 19
(1 row)

SELECT count(*) FROM
Expand Down Expand Up @@ -716,11 +721,4 @@ DROP INDEX aqo_test0_idx_a;
DROP TABLE aqo_test0;
DROP INDEX aqo_test1_idx_a;
DROP TABLE aqo_test1;
-- XXX: extension dropping doesn't clear file storage. Do it manually.
SELECT 1 FROM aqo_reset();
?column?
----------
1
(1 row)

DROP EXTENSION aqo;
35 changes: 20 additions & 15 deletions expected/clean_aqo_data.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;
CREATE EXTENSION IF NOT EXISTS aqo;
SELECT true AS success FROM aqo_reset();
success
---------
t
(1 row)

SET aqo.mode = 'learn';
DROP TABLE IF EXISTS a;
NOTICE: table "a" does not exist, skipping
Expand All @@ -11,9 +16,9 @@ SELECT * FROM a;
(0 rows)

SELECT 'a'::regclass::oid AS a_oid \gset
SELECT true FROM aqo_cleanup();
bool
------
SELECT true AS success FROM aqo_cleanup();
success
---------
t
(1 row)

Expand Down Expand Up @@ -54,9 +59,9 @@ SELECT count(*) FROM aqo_query_stat WHERE
(1 row)

DROP TABLE a;
SELECT true FROM aqo_cleanup();
bool
------
SELECT true AS success FROM aqo_cleanup();
success
---------
t
(1 row)

Expand Down Expand Up @@ -119,7 +124,7 @@ SELECT 'b'::regclass::oid AS b_oid \gset
SELECT count(*) FROM aqo_data WHERE :a_oid=ANY(oids);
count
-------
2
3
(1 row)

SELECT count(*) FROM aqo_queries WHERE
Expand Down Expand Up @@ -175,9 +180,9 @@ SELECT count(*) FROM aqo_query_stat WHERE
(1 row)

DROP TABLE a;
SELECT true FROM aqo_cleanup();
bool
------
SELECT true AS success FROM aqo_cleanup();
success
---------
t
(1 row)

Expand Down Expand Up @@ -253,9 +258,9 @@ SELECT count(*) FROM aqo_query_stat WHERE
(1 row)

DROP TABLE b;
SELECT true FROM aqo_cleanup();
bool
------
SELECT true AS success FROM aqo_cleanup();
success
---------
t
(1 row)

Expand Down
Loading