11#
22# MAX_EXECUTION_TIME hint testing
33#
4- CREATE TABLE t1 (a INT, b VARCHAR(300));
5- INSERT INTO t1 VALUES (1, 'string');
6- INSERT INTO t1 SELECT * FROM t1;
7- INSERT INTO t1 SELECT * FROM t1;
8- INSERT INTO t1 SELECT * FROM t1;
9- INSERT INTO t1 SELECT * FROM t1;
10- INSERT INTO t1 SELECT * FROM t1;
11- INSERT INTO t1 SELECT * FROM t1;
12- INSERT INTO t1 SELECT * FROM t1;
13- INSERT INTO t1 SELECT * FROM t1;
14- INSERT INTO t1 SELECT * FROM t1;
4+ CREATE TABLE t1 (a INT);
5+ INSERT INTO t1 SELECT seq FROM seq_1_to_5000;
156# Correct hint usage
167SELECT /*+ MAX_EXECUTION_TIME(10) */* FROM t1 a, t1 b;
178ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
18- EXPLAIN EXTENDED SELECT /*+ MAX_EXECUTION_TIME(000149 ) */* FROM t1;
9+ EXPLAIN EXTENDED SELECT /*+ MAX_EXECUTION_TIME(0001490 ) */* FROM t1;
1910id select_type table type possible_keys key key_len ref rows filtered Extra
20- 1 SIMPLE t1 ALL NULL NULL NULL NULL 512 100.00
11+ 1 SIMPLE t1 ALL NULL NULL NULL NULL 5000 100.00
2112Warnings:
22- Note 1003 select /*+ MAX_EXECUTION_TIME(000149 ) */ `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b ` from `test`.`t1`
23- SELECT /*+ MAX_EXECUTION_TIME(20) */ *, SLEEP(1) FROM t1 UNION SELECT 1, 2, 3 ;
13+ Note 1003 select /*+ MAX_EXECUTION_TIME(0001490 ) */ `test`.`t1`.`a` AS `a` from `test`.`t1`
14+ SELECT /*+ MAX_EXECUTION_TIME(20) */ *, SLEEP(1) FROM t1 UNION SELECT 1, 2;
2415ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
25- (SELECT /*+ MAX_EXECUTION_TIME(30 ) */ *, SLEEP(1) FROM t1) UNION (SELECT 1, 2, 3 );
16+ (SELECT /*+ MAX_EXECUTION_TIME(300 ) */ *, SLEEP(1) FROM t1) UNION (SELECT 1, 2);
2617ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
27- ((SELECT /*+ MAX_EXECUTION_TIME(50 ) */ *, SLEEP(1) FROM t1));
18+ ((SELECT /*+ MAX_EXECUTION_TIME(500 ) */ *, SLEEP(1) FROM t1));
2819ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
2920# Make sure the hint overrides global/session/statement settings.
3021# Global setting 30 seconds, won't be exceeded for sure
3122SET @@max_statement_time = 30;
32- SELECT /*+ MAX_EXECUTION_TIME(10) */* FROM t1 a, t1 b;
23+ SELECT /*+ MAX_EXECUTION_TIME(10)*/ count(*) FROM t1 a natural join t1 b natural join t1 c ;
3324ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
34- # Session setting 10 seconds, too long to be exceeded
35- SET SESSION max_statement_time = 10 ;
36- SELECT /*+ MAX_EXECUTION_TIME(15) */* FROM t1 a, t1 b;
25+ # Session setting 30 seconds, too long to be exceeded
26+ SET SESSION max_statement_time = 30 ;
27+ SELECT /*+ MAX_EXECUTION_TIME(15) */ count(*) FROM t1 a natural join t1 b natural join t1 c ;
3728ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
3829SET STATEMENT max_statement_time = 20 FOR
39- SELECT /*+ MAX_EXECUTION_TIME(5) */* FROM t1 a, t1 b;
30+ SELECT /*+ MAX_EXECUTION_TIME(5)*/ count(*) FROM t1 a natural join t1 b natural join t1 c ;
4031ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
4132# Check that prepared statements process the hint correctly
4233PREPARE s FROM 'SELECT /*+ MAX_EXECUTION_TIME(20) */ seq, SLEEP(1) FROM seq_1_to_10';
@@ -45,29 +36,29 @@ ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
4536EXECUTE s;
4637ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
4738# Hint duplication
48- SELECT /*+ MAX_EXECUTION_TIME(10 ) MAX_EXECUTION_TIME(100) */ count(*) FROM t1;
39+ SELECT /*+ MAX_EXECUTION_TIME(50000 ) MAX_EXECUTION_TIME(100) */ count(*) FROM t1;
4940count(*)
50- 512
41+ 5000
5142Warnings:
5243Warning 4219 Hint MAX_EXECUTION_TIME(100) is ignored as conflicting/duplicated
5344# Wrong values
5445SELECT /*+ MAX_EXECUTION_TIME(0) */ count(*) FROM t1;
5546count(*)
56- 512
47+ 5000
5748Warnings:
5849Warning 1912 Incorrect value '0' for option 'MAX_EXECUTION_TIME'
5950SELECT /*+ MAX_EXECUTION_TIME(-1) */ count(*) FROM t1;
6051count(*)
61- 512
52+ 5000
6253Warnings:
6354Warning 1064 Optimizer hint syntax error near '-1) */ count(*) FROM t1' at line 1
6455SELECT /*+ MAX_EXECUTION_TIME(4294967296) */ count(*) FROM t1;
6556count(*)
66- 512
57+ 5000
6758Warnings:
6859Warning 1912 Incorrect value '4294967296' for option 'MAX_EXECUTION_TIME'
6960
70- # only SELECT statements supports the MAX_EXECUTION_TIME hint (warning):
61+ # only SELECT statements support the MAX_EXECUTION_TIME hint (warning):
7162
7263CREATE TABLE t2 (i INT);
7364INSERT /*+ MAX_EXECUTION_TIME(10) */ INTO t2 SELECT 1;
@@ -102,18 +93,18 @@ SELECT 1 FROM (SELECT /*+ MAX_EXECUTION_TIME(10) */ 1) a;
10293Warnings:
10394Warning 4172 'MAX_EXECUTION_TIME(10)' is not allowed in this context
10495# Hint is allowed only for the first select of UNION (warning):
105- SELECT /*+ MAX_EXECUTION_TIME(20 ) */ count(*) FROM t1
96+ SELECT /*+ MAX_EXECUTION_TIME(50000 ) */ count(*) FROM t1
10697UNION
107- SELECT /*+ MAX_EXECUTION_TIME(30 ) */ count(*) FROM t1;
98+ SELECT /*+ MAX_EXECUTION_TIME(3 ) */ count(*) FROM t1;
10899count(*)
109- 512
100+ 5000
110101Warnings:
111- Warning 4219 Hint MAX_EXECUTION_TIME(30 ) is ignored as conflicting/duplicated
102+ Warning 4219 Hint MAX_EXECUTION_TIME(3 ) is ignored as conflicting/duplicated
112103SELECT count(*) FROM t1
113104UNION
114105SELECT /*+ MAX_EXECUTION_TIME(30) */ count(*) FROM t1;
115106count(*)
116- 512
107+ 5000
117108Warnings:
118109Warning 4172 'MAX_EXECUTION_TIME(30)' is not allowed in this context
119110# Check that hint actually works:
0 commit comments