|
| 1 | +DROP TABLE IF EXISTS a,b CASCADE; |
| 2 | +NOTICE: table "a" does not exist, skipping |
| 3 | +NOTICE: table "b" does not exist, skipping |
| 4 | +CREATE TABLE a (x1 int, x2 int, x3 int); |
| 5 | +INSERT INTO a (x1, x2, x3) SELECT mod(ival,4), mod(ival,10), mod(ival,10) FROM generate_series(1,100) As ival; |
| 6 | +CREATE TABLE b (y1 int, y2 int, y3 int); |
| 7 | +INSERT INTO b (y1, y2, y3) SELECT mod(ival + 1,4), mod(ival + 1,10), mod(ival + 1,10) FROM generate_series(1,100) As ival; |
| 8 | +CREATE EXTENSION IF NOT EXISTS aqo; |
| 9 | +SET aqo.join_threshold = 0; |
| 10 | +SET aqo.mode = 'learn'; |
| 11 | +SET aqo.show_details = 'off'; |
| 12 | +SET aqo.learn_statement_timeout = 'on'; |
| 13 | +SET statement_timeout = 1500; -- [1.5s] |
| 14 | +SET aqo.statement_timeout = 500; -- [0.5s] |
| 15 | +SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1; |
| 16 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 0 |
| 17 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 1 |
| 18 | + count | count |
| 19 | +-------+------- |
| 20 | + 62500 | 62500 |
| 21 | +(1 row) |
| 22 | + |
| 23 | +select smart_timeout, count_increase_timeout from aqo_queries, aqo_query_texts |
| 24 | + where query_text = 'SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1;' |
| 25 | + and aqo_query_texts.queryid = aqo_queries.queryid limit 1; |
| 26 | + smart_timeout | count_increase_timeout |
| 27 | +---------------+------------------------ |
| 28 | + 1 | 1 |
| 29 | +(1 row) |
| 30 | + |
| 31 | +SET aqo.learn_statement_timeout = 'off'; |
| 32 | +SET aqo.statement_timeout = 1000; -- [1s] |
| 33 | +INSERT INTO a (x1, x2, x3) SELECT mod(ival,20), mod(ival,10), mod(ival,10) FROM generate_series(1,1000) As ival; |
| 34 | +SET aqo.learn_statement_timeout = 'on'; |
| 35 | +SET aqo.statement_timeout = 500; -- [0.5s] |
| 36 | +SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1; |
| 37 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 1 |
| 38 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 6 |
| 39 | + count | count |
| 40 | +--------+-------- |
| 41 | + 563300 | 562500 |
| 42 | +(1 row) |
| 43 | + |
| 44 | +select smart_timeout, count_increase_timeout from aqo_queries, aqo_query_texts |
| 45 | + where query_text = 'SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1;' |
| 46 | + and aqo_query_texts.queryid = aqo_queries.queryid limit 1; |
| 47 | + smart_timeout | count_increase_timeout |
| 48 | +---------------+------------------------ |
| 49 | + 6 | 2 |
| 50 | +(1 row) |
| 51 | + |
| 52 | +SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1; |
| 53 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 6 |
| 54 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 63 |
| 55 | + count | count |
| 56 | +--------+-------- |
| 57 | + 563300 | 562500 |
| 58 | +(1 row) |
| 59 | + |
| 60 | +select smart_timeout, count_increase_timeout from aqo_queries, aqo_query_texts |
| 61 | + where query_text = 'SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1;' |
| 62 | + and aqo_query_texts.queryid = aqo_queries.queryid limit 1; |
| 63 | + smart_timeout | count_increase_timeout |
| 64 | +---------------+------------------------ |
| 65 | + 63 | 3 |
| 66 | +(1 row) |
| 67 | + |
| 68 | +SET statement_timeout = 100; -- [0.1s] |
| 69 | +SET aqo.statement_timeout = 150; |
| 70 | +SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1; |
| 71 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 63 |
| 72 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 1728 |
| 73 | + count | count |
| 74 | +--------+-------- |
| 75 | + 563300 | 562500 |
| 76 | +(1 row) |
| 77 | + |
| 78 | +select smart_timeout, count_increase_timeout from aqo_queries, aqo_query_texts |
| 79 | + where query_text = 'SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1;' |
| 80 | + and aqo_query_texts.queryid = aqo_queries.queryid limit 1; |
| 81 | + smart_timeout | count_increase_timeout |
| 82 | +---------------+------------------------ |
| 83 | + 1728 | 4 |
| 84 | +(1 row) |
| 85 | + |
| 86 | +SELECT 1 FROM aqo_reset(); |
| 87 | + ?column? |
| 88 | +---------- |
| 89 | + 1 |
| 90 | +(1 row) |
| 91 | + |
| 92 | +DROP TABLE a; |
| 93 | +DROP TABLE b; |
| 94 | +DROP EXTENSION aqo; |
0 commit comments