|
| 1 | +DROP TABLE IF EXISTS a,b CASCADE; |
| 2 | +CREATE TABLE a (x1 int, x2 int, x3 int); |
| 3 | +INSERT INTO a (x1, x2, x3) SELECT mod(ival,4), mod(ival,10), mod(ival,10) FROM generate_series(1,100) As ival; |
| 4 | +CREATE TABLE b (y1 int, y2 int, y3 int); |
| 5 | +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; |
| 6 | +CREATE EXTENSION IF NOT EXISTS aqo; |
| 7 | +SET aqo.join_threshold = 0; |
| 8 | +SET aqo.mode = 'learn'; |
| 9 | +SET aqo.show_details = 'off'; |
| 10 | +SET aqo.learn_statement_timeout = 'on'; |
| 11 | +SET statement_timeout = 2500; -- [2.5s] |
| 12 | +SET aqo.statement_timeout = 5000; |
| 13 | +SELECT pg_sleep(2),count(x1),count(y1) FROM A,B WHERE x1 = 5 AND x2 = 5 AND A.x1 = B.y1; |
| 14 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 0 |
| 15 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 1 |
| 16 | + pg_sleep | count | count |
| 17 | +----------+-------+------- |
| 18 | + | 0 | 0 |
| 19 | +(1 row) |
| 20 | + |
| 21 | +select queryid, smart_timeout, count_increase_timeout from aqo_queries where queryid <> 0 and count_increase_timeout > 0 limit 1; |
| 22 | + queryid | smart_timeout | count_increase_timeout |
| 23 | +---------------------+---------------+------------------------ |
| 24 | + 1781875614098811285 | 1 | 1 |
| 25 | +(1 row) |
| 26 | + |
| 27 | +INSERT INTO a (x1, x2, x3) SELECT mod(ival,20), mod(ival,10), mod(ival,10) FROM generate_series(1,1000) As ival; |
| 28 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 0 |
| 29 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 1 |
| 30 | +SELECT pg_sleep(2),count(x1),count(y1) FROM A,B WHERE x1 = 5 AND x2 = 5 AND A.x1 = B.y1; |
| 31 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 1 |
| 32 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 6 |
| 33 | + pg_sleep | count | count |
| 34 | +----------+-------+------- |
| 35 | + | 0 | 0 |
| 36 | +(1 row) |
| 37 | + |
| 38 | +select queryid, smart_timeout, count_increase_timeout from aqo_queries where queryid <> 0 and count_increase_timeout > 1 limit 1; |
| 39 | + queryid | smart_timeout | count_increase_timeout |
| 40 | +---------------------+---------------+------------------------ |
| 41 | + 1781875614098811285 | 6 | 2 |
| 42 | +(1 row) |
| 43 | + |
| 44 | +SELECT pg_sleep(2),count(x1),count(y1) FROM A,B WHERE x1 = 5 AND x2 = 5 AND A.x1 = B.y1; |
| 45 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 6 |
| 46 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 63 |
| 47 | + pg_sleep | count | count |
| 48 | +----------+-------+------- |
| 49 | + | 0 | 0 |
| 50 | +(1 row) |
| 51 | + |
| 52 | +select queryid, smart_timeout, count_increase_timeout from aqo_queries where queryid <> 0 and count_increase_timeout > 2 limit 1; |
| 53 | + queryid | smart_timeout | count_increase_timeout |
| 54 | +---------------------+---------------+------------------------ |
| 55 | + 1781875614098811285 | 63 | 3 |
| 56 | +(1 row) |
| 57 | + |
| 58 | +SET aqo.statement_timeout = 1500; -- [1.5s] |
| 59 | +SELECT pg_sleep(1),count(x1),count(y1) FROM A,B WHERE x1 > 5 AND x2 > 5 AND x3 < 10 AND A.x1 = B.y1; |
| 60 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 0 |
| 61 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 1 |
| 62 | + pg_sleep | count | count |
| 63 | +----------+-------+------- |
| 64 | + | 0 | 0 |
| 65 | +(1 row) |
| 66 | + |
| 67 | +INSERT INTO b (y1, y2, y3) SELECT mod(ival,20), mod(ival,10), mod(ival,10) FROM generate_series(1,1000) As ival; |
| 68 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 0 |
| 69 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 1 |
| 70 | +SELECT pg_sleep(1),count(x1),count(y1) FROM A,B WHERE x1 > 5 AND x2 > 5 AND x3 < 10 AND A.x1 = B.y1; |
| 71 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 1 |
| 72 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 6 |
| 73 | + pg_sleep | count | count |
| 74 | +----------+-------+------- |
| 75 | + | 20000 | 20000 |
| 76 | +(1 row) |
| 77 | + |
| 78 | +select queryid, smart_timeout, count_increase_timeout from aqo_queries where queryid <> 0 and count_increase_timeout > 1 limit 2; |
| 79 | + queryid | smart_timeout | count_increase_timeout |
| 80 | +---------------------+---------------+------------------------ |
| 81 | + 3518970893927378223 | 6 | 2 |
| 82 | + 1781875614098811285 | 63 | 3 |
| 83 | +(2 rows) |
| 84 | + |
| 85 | +SELECT pg_sleep(1),count(x1),count(y1) FROM A,B WHERE x1 > 5 AND x2 > 5 AND x3 < 10 AND A.x1 = B.y1; |
| 86 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 6 |
| 87 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 63 |
| 88 | + pg_sleep | count | count |
| 89 | +----------+-------+------- |
| 90 | + | 20000 | 20000 |
| 91 | +(1 row) |
| 92 | + |
| 93 | +select queryid, smart_timeout, count_increase_timeout from aqo_queries where queryid <> 0 and count_increase_timeout > 2 limit 2; |
| 94 | + queryid | smart_timeout | count_increase_timeout |
| 95 | +---------------------+---------------+------------------------ |
| 96 | + 3518970893927378223 | 63 | 3 |
| 97 | + 1781875614098811285 | 63 | 3 |
| 98 | +(2 rows) |
| 99 | + |
| 100 | +SET aqo.statement_timeout = 15; |
| 101 | +SELECT pg_sleep(1),count(x1),count(y1) FROM A,B WHERE x1 > 5 AND x2 > 5 AND x3 < 10 AND A.x1 = B.y1; |
| 102 | +NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 15 |
| 103 | +NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 1728 |
| 104 | + pg_sleep | count | count |
| 105 | +----------+-------+------- |
| 106 | + | 20000 | 20000 |
| 107 | +(1 row) |
| 108 | + |
| 109 | +select queryid, smart_timeout, count_increase_timeout from aqo_queries where queryid <> 0 and count_increase_timeout > 2 limit 2; |
| 110 | + queryid | smart_timeout | count_increase_timeout |
| 111 | +---------------------+---------------+------------------------ |
| 112 | + 3518970893927378223 | 63 | 3 |
| 113 | + 1781875614098811285 | 63 | 3 |
| 114 | +(2 rows) |
| 115 | + |
| 116 | +SELECT 1 FROM aqo_reset(); |
| 117 | + ?column? |
| 118 | +---------- |
| 119 | + 1 |
| 120 | +(1 row) |
| 121 | + |
| 122 | +DROP EXTENSION aqo; |