| 1 |
SET @old_log_output= @@global.log_output; |
| 2 |
SET @old_slow_query_log= @@global.slow_query_log; |
| 3 |
SET @old_long_query_time= @@session.long_query_time; |
| 4 |
SET @old_log_slow_disable_statements= @@global.log_slow_disabled_statements; |
| 5 |
SET @@session.log_slow_verbosity="explain,innodb,query_plan"; |
| 6 |
CREATE TABLE t1 (i INT PRIMARY KEY AUTO_INCREMENT, j blob) ENGINE=MyISAM; |
| 7 |
insert into t1 (j) values ('a'),('b'),('c'),('d'); |
| 8 |
create table t2 (a int auto_increment primary key) engine=myisam; |
| 9 |
SET GLOBAL log_output = 'file,table'; |
| 10 |
SET GLOBAL slow_query_log = on; |
| 11 |
CREATE PROCEDURE slow() |
| 12 |
BEGIN |
| 13 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b'; |
| 14 |
SELECT count(*) from t1 where j>'a'; |
| 15 |
insert into t2 () values(); |
| 16 |
END |
| 17 |
$ |
| 18 |
CREATE PROCEDURE slow2() |
| 19 |
BEGIN |
| 20 |
SELECT j,count(*) from t1 group by j; |
| 21 |
create temporary table t3 (a int); |
| 22 |
alter table t3 add column (b int); |
| 23 |
call slow(); |
| 24 |
drop temporary table t3; |
| 25 |
SELECT j,count(*)+1 from t1 group by j,i; |
| 26 |
END |
| 27 |
$ |
| 28 |
SET SESSION long_query_time = 0; |
| 29 |
SELECT @@log_slow_disabled_statements; |
| 30 |
@@log_slow_disabled_statements |
| 31 |
sp |
| 32 |
TRUNCATE TABLE mysql.slow_log; |
| 33 |
ALTER TABLE t1 add column extra int; |
| 34 |
CALL slow2(); |
| 35 |
j count(*) |
| 36 |
a 1 |
| 37 |
b 1 |
| 38 |
c 1 |
| 39 |
d 1 |
| 40 |
count(if(sleep(1) >= 0,0,NULL)) |
| 41 |
2 |
| 42 |
count(*) |
| 43 |
3 |
| 44 |
j count(*)+1 |
| 45 |
a 2 |
| 46 |
b 2 |
| 47 |
c 2 |
| 48 |
d 2 |
| 49 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part2'; |
| 50 |
count(if(sleep(1) >= 0,0,NULL)) |
| 51 |
2 |
| 52 |
--> |
| 53 |
SELECT sql_text FROM mysql.slow_log where sql_text <> "Close stmt" and sql_text <> "Prepare"; |
| 54 |
sql_text |
| 55 |
TRUNCATE TABLE mysql.slow_log |
| 56 |
ALTER TABLE t1 add column extra int |
| 57 |
CALL slow2() |
| 58 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part2' |
| 59 |
<-- |
| 60 |
SET SESSION log_slow_disabled_statements="call,admin"; |
| 61 |
TRUNCATE TABLE mysql.slow_log; |
| 62 |
ALTER TABLE t1 add column extra2 int; |
| 63 |
CALL slow2(); |
| 64 |
j count(*) |
| 65 |
a 1 |
| 66 |
b 1 |
| 67 |
c 1 |
| 68 |
d 1 |
| 69 |
count(if(sleep(1) >= 0,0,NULL)) |
| 70 |
2 |
| 71 |
count(*) |
| 72 |
3 |
| 73 |
j count(*)+1 |
| 74 |
a 2 |
| 75 |
b 2 |
| 76 |
c 2 |
| 77 |
d 2 |
| 78 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part3'; |
| 79 |
count(if(sleep(1) >= 0,0,NULL)) |
| 80 |
2 |
| 81 |
--> |
| 82 |
SELECT sql_text FROM mysql.slow_log where sql_text <> "Close stmt" and sql_text <> "Prepare"; |
| 83 |
sql_text |
| 84 |
TRUNCATE TABLE mysql.slow_log |
| 85 |
SELECT j,count(*) from t1 group by j |
| 86 |
create temporary table t3 (a int) |
| 87 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b' |
| 88 |
SELECT count(*) from t1 where j>'a' |
| 89 |
insert into t2 () values() |
| 90 |
drop temporary table t3 |
| 91 |
SELECT j,count(*)+1 from t1 group by j,i |
| 92 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part3' |
| 93 |
<-- |
| 94 |
SET SESSION log_slow_disabled_statements=""; |
| 95 |
TRUNCATE TABLE mysql.slow_log; |
| 96 |
ALTER TABLE t1 add column extra3 int; |
| 97 |
CALL slow2(); |
| 98 |
j count(*) |
| 99 |
a 1 |
| 100 |
b 1 |
| 101 |
c 1 |
| 102 |
d 1 |
| 103 |
count(if(sleep(1) >= 0,0,NULL)) |
| 104 |
2 |
| 105 |
count(*) |
| 106 |
3 |
| 107 |
j count(*)+1 |
| 108 |
a 2 |
| 109 |
b 2 |
| 110 |
c 2 |
| 111 |
d 2 |
| 112 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part4'; |
| 113 |
count(if(sleep(1) >= 0,0,NULL)) |
| 114 |
2 |
| 115 |
--> |
| 116 |
SELECT sql_text FROM mysql.slow_log where sql_text <> "Close stmt" and sql_text <> "Prepare"; |
| 117 |
sql_text |
| 118 |
TRUNCATE TABLE mysql.slow_log |
| 119 |
ALTER TABLE t1 add column extra3 int |
| 120 |
SELECT j,count(*) from t1 group by j |
| 121 |
create temporary table t3 (a int) |
| 122 |
alter table t3 add column (b int) |
| 123 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b' |
| 124 |
SELECT count(*) from t1 where j>'a' |
| 125 |
insert into t2 () values() |
| 126 |
call slow() |
| 127 |
drop temporary table t3 |
| 128 |
SELECT j,count(*)+1 from t1 group by j,i |
| 129 |
CALL slow2() |
| 130 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part4' |
| 131 |
<-- |
| 132 |
SET SESSION log_slow_disabled_statements="call,admin,slave,sp"; |
| 133 |
TRUNCATE TABLE mysql.slow_log; |
| 134 |
ALTER TABLE t1 add column extra4 int; |
| 135 |
CALL slow2(); |
| 136 |
j count(*) |
| 137 |
a 1 |
| 138 |
b 1 |
| 139 |
c 1 |
| 140 |
d 1 |
| 141 |
count(if(sleep(1) >= 0,0,NULL)) |
| 142 |
2 |
| 143 |
count(*) |
| 144 |
3 |
| 145 |
j count(*)+1 |
| 146 |
a 2 |
| 147 |
b 2 |
| 148 |
c 2 |
| 149 |
d 2 |
| 150 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part5'; |
| 151 |
count(if(sleep(1) >= 0,0,NULL)) |
| 152 |
2 |
| 153 |
--> |
| 154 |
SELECT sql_text FROM mysql.slow_log where sql_text <> "Close stmt" and sql_text <> "Prepare"; |
| 155 |
sql_text |
| 156 |
TRUNCATE TABLE mysql.slow_log |
| 157 |
SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part5' |
| 158 |
<-- |
| 159 |
DROP TABLE t1,t2; |
| 160 |
DROP PROCEDURE slow; |
| 161 |
DROP PROCEDURE slow2; |
| 162 |
SET @@session.long_query_time= @old_long_query_time; |
| 163 |
TRUNCATE TABLE mysql.slow_log; |
| 164 |
SET @@global.log_output= @old_log_output; |
| 165 |
SET @@global.slow_query_log= @old_slow_query_log; |
| 166 |
SET @@global.log_slow_disabled_statements= @old_log_slow_disable_statements; |