@@ -17,38 +17,38 @@ BEGIN
1717 END IF;
1818 END LOOP;
1919END; $$;
20- CREATE TABLE t AS SELECT * FROM generate_series(1,100 ) AS x;
20+ CREATE TABLE t AS SELECT * FROM generate_series(1,50 ) AS x;
2121ANALYZE t;
2222DELETE FROM t WHERE x > 5; -- Force optimizer to make overestimated prediction.
2323CREATE EXTENSION IF NOT EXISTS aqo;
2424SET aqo.join_threshold = 0;
2525SET aqo.mode = 'learn';
2626SET aqo.show_details = 'off';
2727SET aqo.learn_statement_timeout = 'on';
28- SET statement_timeout = 800 ; -- [0.8s ]
29- SELECT *, pg_sleep(1) FROM t;
28+ SET statement_timeout = 100 ; -- [0.1s ]
29+ SELECT *, pg_sleep(0. 1) FROM t;
3030NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data.
3131ERROR: canceling statement due to statement timeout
3232SELECT check_estimated_rows('SELECT *, pg_sleep(1) FROM t;'); -- haven't any partial data
3333 check_estimated_rows
3434----------------------
35- 100
35+ 50
3636(1 row)
3737
3838-- Don't learn because running node has smaller cardinality than an optimizer prediction
39- SET statement_timeout = 3500 ;
40- SELECT *, pg_sleep(1) FROM t;
39+ SET statement_timeout = 400 ;
40+ SELECT *, pg_sleep(0. 1) FROM t;
4141NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data.
4242ERROR: canceling statement due to statement timeout
4343SELECT check_estimated_rows('SELECT *, pg_sleep(1) FROM t;');
4444 check_estimated_rows
4545----------------------
46- 100
46+ 50
4747(1 row)
4848
4949-- We have a real learning data.
50- SET statement_timeout = 10000 ;
51- SELECT *, pg_sleep(1) FROM t;
50+ SET statement_timeout = 8000 ;
51+ SELECT *, pg_sleep(0. 1) FROM t;
5252 x | pg_sleep
5353---+----------
5454 1 |
@@ -74,8 +74,8 @@ SELECT 1 FROM aqo_reset();
7474 1
7575(1 row)
7676
77- SET statement_timeout = 800 ;
78- SELECT *, pg_sleep(1) FROM t; -- Not learned
77+ SET statement_timeout = 100 ;
78+ SELECT *, pg_sleep(0. 1) FROM t; -- Not learned
7979NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data.
8080ERROR: canceling statement due to statement timeout
8181SELECT check_estimated_rows('SELECT *, pg_sleep(1) FROM t;');
@@ -84,18 +84,18 @@ SELECT check_estimated_rows('SELECT *, pg_sleep(1) FROM t;');
8484 2
8585(1 row)
8686
87- SET statement_timeout = 3500 ;
88- SELECT *, pg_sleep(1) FROM t; -- Learn!
87+ SET statement_timeout = 500 ;
88+ SELECT *, pg_sleep(0. 1) FROM t; -- Learn!
8989NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data.
9090ERROR: canceling statement due to statement timeout
9191SELECT check_estimated_rows('SELECT *, pg_sleep(1) FROM t;');
9292 check_estimated_rows
9393----------------------
94- 3
94+ 4
9595(1 row)
9696
97- SET statement_timeout = 5500 ;
98- SELECT *, pg_sleep(1) FROM t; -- Get reliable data
97+ SET statement_timeout = 800 ;
98+ SELECT *, pg_sleep(0. 1) FROM t; -- Get reliable data
9999 x | pg_sleep
100100---+----------
101101 1 |
0 commit comments