| 1 |
# Tests for PERFORMANCE_SCHEMA |
| 2 |
|
| 3 |
--source ../include/start_server_common.inc |
| 4 |
|
| 5 |
############################# |
| 6 |
# Setup database and tables. |
| 7 |
############################# |
| 8 |
--disable_warnings |
| 9 |
drop table if exists db1.t1; |
| 10 |
drop database if exists db1; |
| 11 |
--enable_warnings |
| 12 |
create database db1; |
| 13 |
create table db1.t1 (a int, b char(10) default 'default', |
| 14 |
unique key uidx(a)); |
| 15 |
|
| 16 |
####################### |
| 17 |
# Execute few queries. |
| 18 |
####################### |
| 19 |
insert into db1.t1 values('1', 'abc'); |
| 20 |
insert into db1.t1 values('2', 'abc'); |
| 21 |
select * from db1.t1 where a='1'; |
| 22 |
|
| 23 |
##################################################### |
| 24 |
# Run few queries on Performance Schema stats tables. |
| 25 |
##################################################### |
| 26 |
# There should be 3 entries in following table. 2 for insert and 1 for select. |
| 27 |
# This is because lock stats are still in the table handles |
| 28 |
select COUNT_STAR from performance_schema.table_io_waits_summary_by_table |
| 29 |
where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1'; |
| 30 |
# There should be 1 entry in following table. Thats is for select. |
| 31 |
# This is because lock stats are still in the table handles |
| 32 |
select COUNT_STAR from performance_schema.table_io_waits_summary_by_index_usage |
| 33 |
where INDEX_NAME!='NULL'; |
| 34 |
|
| 35 |
# Now force aggregation by closing table handles |
| 36 |
FLUSH TABLES; |
| 37 |
|
| 38 |
# Stats are now missing |
| 39 |
select COUNT_STAR from performance_schema.table_io_waits_summary_by_table |
| 40 |
where OBJECT_SCHEMA='db1' and OBJECT_NAME='t1'; |
| 41 |
|
| 42 |
# Stats are now missing |
| 43 |
select COUNT_STAR from performance_schema.table_io_waits_summary_by_index_usage |
| 44 |
where INDEX_NAME!='NULL'; |
| 45 |
|
| 46 |
# Expect INDEX_STAT lost |
| 47 |
--disable_warnings |
| 48 |
select variable_value > 0 from performance_schema.global_status |
| 49 |
where variable_name like 'PERFORMANCE_SCHEMA_INDEX_STAT_LOST'; |
| 50 |
|
| 51 |
# While at it, check that FLUSH STATUS Resets the lost counter |
| 52 |
FLUSH STATUS; |
| 53 |
|
| 54 |
select variable_value from performance_schema.global_status |
| 55 |
where variable_name like 'PERFORMANCE_SCHEMA_INDEX_STAT_LOST'; |
| 56 |
--enable_warnings |
| 57 |
|
| 58 |
########### |
| 59 |
# Cleanup. |
| 60 |
########### |
| 61 |
drop database db1; |