Skip to content

Commit 8a99337

Browse files
committed
Set join limit to non-zero value.
We should accept the law of life: people establish their attitude to product with first glance, first use, without learning any optimization techniques. So, most of them will use it with default value of GUCS. According to this fact, set default value of joins limit to higher value and set it to zero manually at each test case.
1 parent 480d9cb commit 8a99337

35 files changed

+35
-48
lines changed

‎aqo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ _PG_init(void)
203203
"Sets the threshold of number of JOINs in query beyond which AQO is used.",
204204
NULL,
205205
&aqo_join_threshold,
206-
0,
206+
3,
207207
0, INT_MAX / 1000,
208208
PGC_USERSET,
209209
0,

‎expected/aqo_CVE-2020-14350.out

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ END
2727
$$ LANGUAGE plpgsql RETURNS NULL ON NULL INPUT;
2828
RESET ROLE;
2929
CREATE EXTENSION aqo;
30+
SET aqo.join_threshold = 0;
3031
-- Test result (must be 'off')
3132
SET ROLE regress_hacker;
3233
SHOW is_superuser;

‎expected/aqo_controlled.out

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ AS (
2626
CREATE INDEX aqo_test2_idx_a ON aqo_test2 (a);
2727
ANALYZE aqo_test2;
2828
CREATE EXTENSION aqo;
29+
SET aqo.join_threshold = 0;
2930
SET aqo.mode = 'controlled';
3031
EXPLAIN (COSTS FALSE)
3132
SELECT * FROM aqo_test0

‎expected/aqo_disabled.out

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ AS (
1717
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
1818
ANALYZE aqo_test1;
1919
CREATE EXTENSION aqo;
20+
SET aqo.join_threshold = 0;
2021
SET aqo.mode = 'controlled';
2122
CREATE TABLE tmp1 AS SELECT * FROM aqo_test0
2223
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;

‎expected/aqo_fdw.out

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CREATE EXTENSION postgres_fdw;
88
SET aqo.mode = 'learn';
99
SET aqo.show_details = 'true'; -- show AQO info for each node and entire query.
1010
SET aqo.show_hash = 'false'; -- a hash value is system-depended. Ignore it.
11+
SET aqo.join_threshold = 0;
1112
DO $d$
1213
BEGIN
1314
EXECUTE $$CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw

‎expected/aqo_forced.out

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ AS (
1717
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
1818
ANALYZE aqo_test1;
1919
CREATE EXTENSION aqo;
20+
SET aqo.join_threshold = 0;
2021
SET aqo.mode = 'controlled';
2122
EXPLAIN (COSTS FALSE)
2223
SELECT * FROM aqo_test0

‎expected/aqo_intelligent.out

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ AS (
1717
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
1818
ANALYZE aqo_test1;
1919
CREATE EXTENSION aqo;
20+
SET aqo.join_threshold = 0;
2021
SET aqo.mode = 'intelligent';
2122
EXPLAIN SELECT * FROM aqo_test0
2223
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;

‎expected/aqo_learn.out

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ AS (
3737
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
3838
ANALYZE aqo_test1;
3939
CREATE EXTENSION aqo;
40+
SET aqo.join_threshold = 0;
4041
SET aqo.mode = 'intelligent';
4142
EXPLAIN SELECT * FROM aqo_test0
4243
WHERE a < 3 AND b < 3 AND c < 3 AND d < 3;

‎expected/clean_aqo_data.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION aqo;
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'learn';
34
DROP TABLE IF EXISTS a;
45
NOTICE: table "a" does not exist, skipping

‎expected/forced_stat_collection.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
\set citizens 1000
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'disabled';
34
SET aqo.force_collect_stat = 'on';
45
CREATE TABLE person (

‎expected/gucs.out

+1-38
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,5 @@
11
CREATE EXTENSION aqo;
2-
-- Check interface variables and their default values. Detect, if default value
3-
-- of a GUC is changed.
4-
SHOW aqo.join_threshold;
5-
aqo.join_threshold
6-
--------------------
7-
0
8-
(1 row)
9-
10-
SHOW aqo.learn_statement_timeout;
11-
aqo.learn_statement_timeout
12-
-----------------------------
13-
off
14-
(1 row)
15-
16-
SHOW aqo.show_hash;
17-
aqo.show_hash
18-
---------------
19-
off
20-
(1 row)
21-
22-
SHOW aqo.show_details;
23-
aqo.show_details
24-
------------------
25-
off
26-
(1 row)
27-
28-
SHOW aqo.force_collect_stat;
29-
aqo.force_collect_stat
30-
------------------------
31-
off
32-
(1 row)
33-
34-
SHOW aqo.mode;
35-
aqo.mode
36-
------------
37-
controlled
38-
(1 row)
39-
2+
SET aqo.join_threshold = 0;
403
SET aqo.mode = 'learn';
414
SET aqo.show_details = true;
425
CREATE TABLE t(x int);

‎expected/plancache.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
-- Tests on interaction of AQO with cached plans.
22
CREATE EXTENSION aqo;
3+
SET aqo.join_threshold = 0;
34
SET aqo.mode = 'intelligent';
45
SET aqo.show_details = 'on';
56
SET aqo.show_hash = 'off';

‎expected/schema.out

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ERROR: no schema has been selected to create in
1212
CREATE SCHEMA IF NOT EXISTS test1;
1313
SET search_path TO test1, public;
1414
CREATE EXTENSION aqo;
15+
SET aqo.join_threshold = 0;
1516
SET aqo.mode = 'intelligent';
1617
CREATE TABLE test (id SERIAL, data TEXT);
1718
INSERT INTO test (data) VALUES ('string');

‎expected/statement_timeout.out

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ CREATE TABLE t AS SELECT * FROM generate_series(1,100) AS x;
2121
ANALYZE t;
2222
DELETE FROM t WHERE x > 5; -- Force optimizer to make overestimated prediction.
2323
CREATE EXTENSION IF NOT EXISTS aqo;
24+
SET aqo.join_threshold = 0;
2425
SET aqo.mode = 'learn';
2526
SET aqo.show_details = 'off';
2627
SET aqo.learn_statement_timeout = 'on';

‎expected/temp_tables.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION aqo;
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'learn';
34
CREATE TEMP TABLE tt();
45
CREATE TABLE pt();

‎expected/top_queries.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION aqo;
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'disabled';
34
SET aqo.force_collect_stat = 'on';
45
--

‎expected/unsupported.out

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION aqo;
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'learn';
34
SET aqo.show_details = 'on';
45
DROP TABLE IF EXISTS t;

‎sql/aqo_CVE-2020-14350.sql

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ $$ LANGUAGE plpgsql RETURNS NULL ON NULL INPUT;
2727

2828
RESET ROLE;
2929
CREATE EXTENSION aqo;
30+
SET aqo.join_threshold = 0;
3031

3132
-- Test result (must be 'off')
3233
SET ROLE regress_hacker;

‎sql/aqo_controlled.sql

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CREATE INDEX aqo_test2_idx_a ON aqo_test2 (a);
2929
ANALYZE aqo_test2;
3030

3131
CREATE EXTENSION aqo;
32+
SET aqo.join_threshold = 0;
3233

3334
SET aqo.mode = 'controlled';
3435

‎sql/aqo_disabled.sql

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ AS (
1818
CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
1919
ANALYZE aqo_test1;
2020
CREATE EXTENSION aqo;
21+
SET aqo.join_threshold = 0;
2122

2223
SET aqo.mode = 'controlled';
2324

‎sql/aqo_fdw.sql

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ CREATE EXTENSION postgres_fdw;
99
SET aqo.mode = 'learn';
1010
SET aqo.show_details = 'true'; -- show AQO info for each node and entire query.
1111
SET aqo.show_hash = 'false'; -- a hash value is system-depended. Ignore it.
12+
SET aqo.join_threshold = 0;
1213

1314
DO $d$
1415
BEGIN

‎sql/aqo_forced.sql

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
1919
ANALYZE aqo_test1;
2020

2121
CREATE EXTENSION aqo;
22+
SET aqo.join_threshold = 0;
2223

2324
SET aqo.mode = 'controlled';
2425

‎sql/aqo_intelligent.sql

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
1919
ANALYZE aqo_test1;
2020

2121
CREATE EXTENSION aqo;
22+
SET aqo.join_threshold = 0;
2223

2324
SET aqo.mode = 'intelligent';
2425

‎sql/aqo_learn.sql

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ CREATE INDEX aqo_test1_idx_a ON aqo_test1 (a);
4040
ANALYZE aqo_test1;
4141

4242
CREATE EXTENSION aqo;
43+
SET aqo.join_threshold = 0;
4344

4445
SET aqo.mode = 'intelligent';
4546

‎sql/clean_aqo_data.sql

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION aqo;
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'learn';
34

45
DROP TABLE IF EXISTS a;

‎sql/forced_stat_collection.sql

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
\set citizens 1000
22

3+
SET aqo.join_threshold = 0;
34
SET aqo.mode = 'disabled';
45
SET aqo.force_collect_stat = 'on';
56

‎sql/gucs.sql

+1-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
CREATE EXTENSION aqo;
2-
3-
-- Check interface variables and their default values. Detect, if default value
4-
-- of a GUC is changed.
5-
SHOW aqo.join_threshold;
6-
SHOW aqo.learn_statement_timeout;
7-
SHOW aqo.show_hash;
8-
SHOW aqo.show_details;
9-
SHOW aqo.force_collect_stat;
10-
SHOW aqo.mode;
2+
SET aqo.join_threshold = 0;
113

124
SET aqo.mode = 'learn';
135
SET aqo.show_details = true;

‎sql/plancache.sql

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
-- Tests on interaction of AQO with cached plans.
22

33
CREATE EXTENSION aqo;
4+
SET aqo.join_threshold = 0;
45
SET aqo.mode = 'intelligent';
56
SET aqo.show_details = 'on';
67
SET aqo.show_hash = 'off';

‎sql/schema.sql

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ CREATE EXTENSION aqo; -- fail
1111
CREATE SCHEMA IF NOT EXISTS test1;
1212
SET search_path TO test1, public;
1313
CREATE EXTENSION aqo;
14+
SET aqo.join_threshold = 0;
1415
SET aqo.mode = 'intelligent';
1516

1617
CREATE TABLE test (id SERIAL, data TEXT);

‎sql/statement_timeout.sql

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ANALYZE t;
2323
DELETE FROM t WHERE x > 5; -- Force optimizer to make overestimated prediction.
2424

2525
CREATE EXTENSION IF NOT EXISTS aqo;
26+
SET aqo.join_threshold = 0;
2627
SET aqo.mode = 'learn';
2728
SET aqo.show_details = 'off';
2829
SET aqo.learn_statement_timeout = 'on';

‎sql/temp_tables.sql

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION aqo;
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'learn';
34

45
CREATE TEMP TABLE tt();

‎sql/top_queries.sql

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION aqo;
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'disabled';
34
SET aqo.force_collect_stat = 'on';
45

‎sql/unsupported.sql

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
CREATE EXTENSION aqo;
2+
SET aqo.join_threshold = 0;
23
SET aqo.mode = 'learn';
34
SET aqo.show_details = 'on';
45

‎t/001_pgbench.pl

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
shared_preload_libraries = 'aqo'
1313
aqo.mode = 'intelligent'
1414
log_statement = 'ddl'
15+
aqo.join_threshold = 0
1516
});
1617

1718
# Test constants. Default values.

‎t/002_pg_stat_statements_aqo.pl

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
aqo.profile_enable = 'true'
1616
aqo.force_collect_stat = 'false'
1717
log_statement = 'ddl' # reduce size of logs.
18+
aqo.join_threshold = 0
1819
});
1920
# Test constants.
2021
my $TRANSACTIONS = 100;

0 commit comments

Comments
 (0)