| 1 |
# Tests for PERFORMANCE_SCHEMA |
| 2 |
|
| 3 |
select connection_id() into @conid; |
| 4 |
|
| 5 |
--echo |
| 6 |
select thread_id from performance_schema.threads |
| 7 |
where PROCESSLIST_ID = @conid |
| 8 |
into @tid; |
| 9 |
|
| 10 |
--echo |
| 11 |
select thread_os_id from performance_schema.threads |
| 12 |
where PROCESSLIST_ID = @conid |
| 13 |
into @osid; |
| 14 |
|
| 15 |
# Debug |
| 16 |
# select @conid, @tid, @osid; |
| 17 |
|
| 18 |
# Test index on THREAD_ID |
| 19 |
|
| 20 |
--echo |
| 21 |
explain select THREAD_ID, NAME from performance_schema.threads |
| 22 |
where thread_id = 1; |
| 23 |
|
| 24 |
--echo |
| 25 |
explain select * from performance_schema.threads |
| 26 |
where thread_id > 1; |
| 27 |
|
| 28 |
--echo |
| 29 |
explain select * from performance_schema.threads |
| 30 |
where thread_id < 1; |
| 31 |
|
| 32 |
--echo |
| 33 |
--replace_column 3 <info> |
| 34 |
select processlist_id = @conid, name, processlist_info |
| 35 |
from performance_schema.threads |
| 36 |
where thread_id = @tid; |
| 37 |
|
| 38 |
# Test index on PROCESSLIST_ID |
| 39 |
|
| 40 |
# The explain output depends on the value of @osid |
| 41 |
--echo |
| 42 |
--disable_warnings |
| 43 |
explain select THREAD_ID, NAME from performance_schema.threads |
| 44 |
where processlist_id = @conid; |
| 45 |
--enable_warnings |
| 46 |
|
| 47 |
--echo |
| 48 |
explain select * from performance_schema.threads |
| 49 |
where processlist_id > 99999; |
| 50 |
|
| 51 |
--echo |
| 52 |
explain select * from performance_schema.threads |
| 53 |
where processlist_id < 99999; |
| 54 |
|
| 55 |
--echo |
| 56 |
--replace_column 3 <info> |
| 57 |
select thread_id = @tid, name, processlist_info |
| 58 |
from performance_schema.threads |
| 59 |
where processlist_id = @conid; |
| 60 |
|
| 61 |
# Test index on THREAD_OS_ID |
| 62 |
|
| 63 |
# The explain output depends on the value of @osid |
| 64 |
--echo |
| 65 |
--disable_warnings |
| 66 |
explain select THREAD_ID, NAME from performance_schema.threads |
| 67 |
where thread_os_id = @osid; |
| 68 |
--enable_warnings |
| 69 |
|
| 70 |
--echo |
| 71 |
explain select * from performance_schema.threads |
| 72 |
where thread_os_id > 99999; |
| 73 |
|
| 74 |
--echo |
| 75 |
explain select * from performance_schema.threads |
| 76 |
where thread_os_id < 99999; |
| 77 |
|
| 78 |
--echo |
| 79 |
--replace_column 3 <info> |
| 80 |
select thread_id - @tid, name, processlist_info |
| 81 |
from performance_schema.threads |
| 82 |
where thread_os_id = @osid; |
| 83 |
|
| 84 |
# Test index on NAME |
| 85 |
|
| 86 |
--echo |
| 87 |
explain select THREAD_ID from performance_schema.threads |
| 88 |
where NAME = "impossible"; |
| 89 |
|
| 90 |
--echo |
| 91 |
explain select THREAD_ID from performance_schema.threads |
| 92 |
where NAME = "thread/sql/main"; |
| 93 |
|
| 94 |
--echo |
| 95 |
explain select * from performance_schema.threads |
| 96 |
where NAME > "foo"; |
| 97 |
|
| 98 |
--echo |
| 99 |
explain select * from performance_schema.threads |
| 100 |
where NAME < "bar"; |
| 101 |
|
| 102 |
--echo |
| 103 |
explain select * from performance_schema.threads |
| 104 |
where NAME like "thread/sql/%"; |
| 105 |
|
| 106 |
--echo |
| 107 |
--replace_column 1 <thread_id> 3 <state> 4 <info> |
| 108 |
select thread_id, name, processlist_state, processlist_info |
| 109 |
from performance_schema.threads |
| 110 |
where NAME = "thread/sql/main" order by thread_id; |
| 111 |
|
| 112 |
# Test index on PROCESSLIST_USER, PROCESSLIST_HOST |
| 113 |
|
| 114 |
--echo |
| 115 |
explain select THREAD_ID from performance_schema.threads |
| 116 |
where PROCESSLIST_USER = "impossible"; |
| 117 |
|
| 118 |
--echo |
| 119 |
explain select THREAD_ID from performance_schema.threads |
| 120 |
where PROCESSLIST_USER = "root"; |
| 121 |
|
| 122 |
--echo |
| 123 |
explain select * from performance_schema.threads |
| 124 |
where PROCESSLIST_USER > "foo"; |
| 125 |
|
| 126 |
--echo |
| 127 |
explain select * from performance_schema.threads |
| 128 |
where PROCESSLIST_USER < "bar"; |
| 129 |
|
| 130 |
--echo |
| 131 |
explain select * from performance_schema.threads |
| 132 |
where PROCESSLIST_USER like "ro%"; |
| 133 |
|
| 134 |
--echo |
| 135 |
--replace_column 1 <thread_id> 4 <state> 5 <info> |
| 136 |
select thread_id, thread_id = @tid, name, processlist_state, processlist_info |
| 137 |
from performance_schema.threads |
| 138 |
where PROCESSLIST_USER = "root" order by thread_id; |
| 139 |
|
| 140 |
--echo |
| 141 |
explain select THREAD_ID from performance_schema.threads |
| 142 |
where PROCESSLIST_USER = "impossible" and PROCESSLIST_HOST = "impossible"; |
| 143 |
|
| 144 |
--echo |
| 145 |
explain select THREAD_ID from performance_schema.threads |
| 146 |
where PROCESSLIST_USER = "root" and PROCESSLIST_HOST = "localhost"; |
| 147 |
|
| 148 |
--echo |
| 149 |
explain select * from performance_schema.threads |
| 150 |
where PROCESSLIST_USER = "foo" and PROCESSLIST_HOST < "foo"; |
| 151 |
|
| 152 |
--echo |
| 153 |
explain select * from performance_schema.threads |
| 154 |
where PROCESSLIST_USER = "foo" and PROCESSLIST_HOST > "bar"; |
| 155 |
|
| 156 |
--echo |
| 157 |
explain select * from performance_schema.threads |
| 158 |
where PROCESSLIST_USER = "foo" and PROCESSLIST_HOST like "bar%"; |
| 159 |
|
| 160 |
--echo |
| 161 |
--replace_column 1 <thread_id> 4 <state> 5 <info> |
| 162 |
select thread_id, thread_id = @tid, name, processlist_state, processlist_info |
| 163 |
from performance_schema.threads |
| 164 |
where PROCESSLIST_USER = "root" and PROCESSLIST_HOST = "localhost" order by thread_id; |
| 165 |
|
| 166 |
# Test index on PROCESSLIST_HOST |
| 167 |
|
| 168 |
--echo |
| 169 |
explain select THREAD_ID from performance_schema.threads |
| 170 |
where PROCESSLIST_HOST = "impossible"; |
| 171 |
|
| 172 |
--echo |
| 173 |
explain select THREAD_ID from performance_schema.threads |
| 174 |
where PROCESSLIST_HOST = "localhost"; |
| 175 |
|
| 176 |
--echo |
| 177 |
explain select * from performance_schema.threads |
| 178 |
where PROCESSLIST_HOST > "foo"; |
| 179 |
|
| 180 |
--echo |
| 181 |
explain select * from performance_schema.threads |
| 182 |
where PROCESSLIST_HOST < "bar"; |
| 183 |
|
| 184 |
--echo |
| 185 |
explain select * from performance_schema.threads |
| 186 |
where PROCESSLIST_HOST like "local%"; |
| 187 |
|
| 188 |
--echo |
| 189 |
--replace_column 1 <thread_id> 4 <state> 5 <info> |
| 190 |
select thread_id, thread_id = @tid, name, processlist_state, processlist_info |
| 191 |
from performance_schema.threads |
| 192 |
where PROCESSLIST_HOST = "localhost" order by (thread_id = @tid), thread_id; |