| 1 |
UPDATE performance_schema.setup_instruments SET enabled = 'NO', timed = 'YES'; |
| 2 |
UPDATE performance_schema.setup_instruments SET enabled = 'YES' |
| 3 |
WHERE name in ('wait/io/table/sql/handler', |
| 4 |
'wait/lock/table/sql/handler'); |
| 5 |
drop procedure if exists before_payload; |
| 6 |
drop procedure if exists after_payload; |
| 7 |
create procedure before_payload() |
| 8 |
begin |
| 9 |
TRUNCATE TABLE performance_schema.table_io_waits_summary_by_index_usage; |
| 10 |
TRUNCATE TABLE performance_schema.table_io_waits_summary_by_table; |
| 11 |
TRUNCATE TABLE performance_schema.events_waits_history_long; |
| 12 |
TRUNCATE TABLE performance_schema.events_waits_history; |
| 13 |
TRUNCATE TABLE performance_schema.events_waits_current; |
| 14 |
end |
| 15 |
$$ |
| 16 |
create procedure after_payload() |
| 17 |
begin |
| 18 |
select count(1) as number_seen, |
| 19 |
OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, |
| 20 |
OPERATION, NUMBER_OF_BYTES |
| 21 |
from performance_schema.events_waits_history_long |
| 22 |
where OBJECT_SCHEMA = "test" |
| 23 |
group by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, OPERATION, NUMBER_OF_BYTES; |
| 24 |
select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME, |
| 25 |
COUNT_STAR, COUNT_READ, COUNT_WRITE |
| 26 |
from performance_schema.table_io_waits_summary_by_index_usage |
| 27 |
where OBJECT_SCHEMA = "test" |
| 28 |
order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, INDEX_NAME; |
| 29 |
select OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME, |
| 30 |
COUNT_STAR, COUNT_READ, COUNT_WRITE |
| 31 |
from performance_schema.table_io_waits_summary_by_table |
| 32 |
where OBJECT_SCHEMA = "test" |
| 33 |
order by OBJECT_TYPE, OBJECT_SCHEMA, OBJECT_NAME; |
| 34 |
end |
| 35 |
$$ |
| 36 |
drop table if exists t1; |
| 37 |
drop table if exists t2; |
| 38 |
drop table if exists t3; |
| 39 |
create table t0(v int); |
| 40 |
create table t1(id1 int, a int); |
| 41 |
create table t2(id1 int, id2 int, b int); |
| 42 |
create table t3(id2 int, id3 int, c int); |
| 43 |
insert into t0 values |
| 44 |
(0), (1), (2), (3), (4), |
| 45 |
(5), (6), (7), (8), (9); |
| 46 |
insert into t1(id1, a) |
| 47 |
select v, 100*v from t0; |
| 48 |
insert into t2(id1, id2, b) |
| 49 |
select X.v, 10*X.v + Y.v, 100*X.v + 10*Y.v |
| 50 |
from t0 X, t0 Y; |
| 51 |
insert into t3(id2, id3, c) |
| 52 |
select 10*X.v + Y.v, 100*X.v + 10*Y.v + Z.v, 100*X.v + 10*Y.v + Z.v |
| 53 |
from t0 X, t0 Y, t0 Z; |
| 54 |
analyze table t1; |
| 55 |
Table Op Msg_type Msg_text |
| 56 |
test.t1 analyze status OK |
| 57 |
analyze table t2; |
| 58 |
Table Op Msg_type Msg_text |
| 59 |
test.t2 analyze status OK |
| 60 |
analyze table t3; |
| 61 |
Table Op Msg_type Msg_text |
| 62 |
test.t3 analyze status OK |
| 63 |
select * from t1 order by a; |
| 64 |
id1 a |
| 65 |
0 0 |
| 66 |
1 100 |
| 67 |
2 200 |
| 68 |
3 300 |
| 69 |
4 400 |
| 70 |
5 500 |
| 71 |
6 600 |
| 72 |
7 700 |
| 73 |
8 800 |
| 74 |
9 900 |
| 75 |
select * from t2 |
| 76 |
where (b >= 180) and (b <= 220) |
| 77 |
order by b; |
| 78 |
id1 id2 b |
| 79 |
1 18 180 |
| 80 |
1 19 190 |
| 81 |
2 20 200 |
| 82 |
2 21 210 |
| 83 |
2 22 220 |
| 84 |
select * from t3 |
| 85 |
where (c >= 587) and (c <= 612) |
| 86 |
order by c; |
| 87 |
id2 id3 c |
| 88 |
58 587 587 |
| 89 |
58 588 588 |
| 90 |
58 589 589 |
| 91 |
59 590 590 |
| 92 |
59 591 591 |
| 93 |
59 592 592 |
| 94 |
59 593 593 |
| 95 |
59 594 594 |
| 96 |
59 595 595 |
| 97 |
59 596 596 |
| 98 |
59 597 597 |
| 99 |
59 598 598 |
| 100 |
59 599 599 |
| 101 |
60 600 600 |
| 102 |
60 601 601 |
| 103 |
60 602 602 |
| 104 |
60 603 603 |
| 105 |
60 604 604 |
| 106 |
60 605 605 |
| 107 |
60 606 606 |
| 108 |
60 607 607 |
| 109 |
60 608 608 |
| 110 |
60 609 609 |
| 111 |
61 610 610 |
| 112 |
61 611 611 |
| 113 |
61 612 612 |
| 114 |
explain select t1.*, t2.*, t3.* |
| 115 |
from t1 join t2 using (id1) join t3 using (id2); |
| 116 |
id select_type table partitions type possible_keys key key_len ref rows filtered Extra |
| 117 |
1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10 100.00 NULL |
| 118 |
1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 100 10.00 Using where; Using join buffer (hash join) |
| 119 |
1 SIMPLE t3 NULL ALL NULL NULL NULL NULL 1000 10.00 Using where; Using join buffer (hash join) |
| 120 |
Warnings: |
| 121 |
Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`id2` = `test`.`t2`.`id2`)) |
| 122 |
call before_payload(); |
| 123 |
select t1.*, t2.*, t3.* |
| 124 |
from t1 join t2 using (id1) join t3 using (id2); |
| 125 |
call after_payload(); |
| 126 |
number_seen OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME OPERATION NUMBER_OF_BYTES |
| 127 |
1 TABLE test t1 NULL read external NULL |
| 128 |
1 TABLE test t2 NULL read external NULL |
| 129 |
1 TABLE test t3 NULL read external NULL |
| 130 |
1 TABLE test t1 NULL fetch 10 |
| 131 |
1 TABLE test t2 NULL fetch 100 |
| 132 |
1 TABLE test t3 NULL fetch 1000 |
| 133 |
OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME COUNT_STAR COUNT_READ COUNT_WRITE |
| 134 |
TABLE test t0 NULL 0 0 0 |
| 135 |
TABLE test t1 NULL 10 10 0 |
| 136 |
TABLE test t2 NULL 100 100 0 |
| 137 |
TABLE test t3 NULL 1000 1000 0 |
| 138 |
OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME COUNT_STAR COUNT_READ COUNT_WRITE |
| 139 |
TABLE test t0 0 0 0 |
| 140 |
TABLE test t1 10 10 0 |
| 141 |
TABLE test t2 100 100 0 |
| 142 |
TABLE test t3 1000 1000 0 |
| 143 |
alter table t1 add unique index(id1); |
| 144 |
alter table t2 add unique index(id2); |
| 145 |
alter table t2 add index(id1); |
| 146 |
alter table t3 add unique index(id3); |
| 147 |
alter table t3 add index(id2); |
| 148 |
explain select t1.*, t2.*, t3.* |
| 149 |
from t1 join t2 using (id1) join t3 using (id2); |
| 150 |
id select_type table partitions type possible_keys key key_len ref rows filtered Extra |
| 151 |
1 SIMPLE t1 NULL ALL id1 NULL NULL NULL 10 100.00 Using where |
| 152 |
1 SIMPLE t2 NULL ref id2,id1 id1 5 test.t1.id1 10 100.00 Using where |
| 153 |
1 SIMPLE t3 NULL ref id2 id2 5 test.t2.id2 10 100.00 NULL |
| 154 |
Warnings: |
| 155 |
Note 1003 /* select#1 */ select `test`.`t1`.`id1` AS `id1`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`id1` AS `id1`,`test`.`t2`.`id2` AS `id2`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`id2` AS `id2`,`test`.`t3`.`id3` AS `id3`,`test`.`t3`.`c` AS `c` from `test`.`t1` join `test`.`t2` join `test`.`t3` where ((`test`.`t2`.`id1` = `test`.`t1`.`id1`) and (`test`.`t3`.`id2` = `test`.`t2`.`id2`)) |
| 156 |
call before_payload(); |
| 157 |
select t1.*, t2.*, t3.* |
| 158 |
from t1 join t2 using (id1) join t3 using (id2); |
| 159 |
call after_payload(); |
| 160 |
number_seen OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME OPERATION NUMBER_OF_BYTES |
| 161 |
1 TABLE test t1 id1 read external NULL |
| 162 |
1 TABLE test t2 id2 read external NULL |
| 163 |
1 TABLE test t3 id3 read external NULL |
| 164 |
11 TABLE test t1 NULL fetch 1 |
| 165 |
110 TABLE test t2 id1 fetch 1 |
| 166 |
100 TABLE test t3 id2 fetch 10 |
| 167 |
OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME INDEX_NAME COUNT_STAR COUNT_READ COUNT_WRITE |
| 168 |
TABLE test t0 NULL 0 0 0 |
| 169 |
TABLE test t1 NULL 11 11 0 |
| 170 |
TABLE test t1 id1 0 0 0 |
| 171 |
TABLE test t2 id1 110 110 0 |
| 172 |
TABLE test t2 id2 0 0 0 |
| 173 |
TABLE test t3 id2 1000 1000 0 |
| 174 |
TABLE test t3 id3 0 0 0 |
| 175 |
OBJECT_TYPE OBJECT_SCHEMA OBJECT_NAME COUNT_STAR COUNT_READ COUNT_WRITE |
| 176 |
TABLE test t0 0 0 0 |
| 177 |
TABLE test t1 11 11 0 |
| 178 |
TABLE test t2 110 110 0 |
| 179 |
TABLE test t3 1000 1000 0 |
| 180 |
drop table t0; |
| 181 |
drop table t1; |
| 182 |
drop table t2; |
| 183 |
drop table t3; |
| 184 |
drop procedure before_payload; |
| 185 |
drop procedure after_payload; |
| 186 |
UPDATE performance_schema.setup_instruments SET enabled = 'YES', timed = 'YES'; |