1.在5.7之前,系统的performance_schema不会默认开启,在5.7之后系统会默认开启(跟系统内存有关系)。performance_schema数据库主要是记录事件的event,sql等等。
开启等待事件instruments;
update setup_instruments set enabled=‘yes‘ and timed=‘yes‘ where name like ‘wait/%‘;
开启等待事件consumers
update setup_consumers set enable=‘yes‘ where name like ‘%wait%‘;
创建一个试图进行查看
create view sys.test_waits as select sum(timer_wait) as timer_wait,sum(number_of_bytes) as number_of_bytes,event_name,operation from events_waits_current where event_name !=‘idle‘ group by event_name,operation;
进行降序查询
select sys.format_time (timer_wait),sys.format_bytes(number_of_bytes),event_name,operation from sys.test_waits where sys.format(timer_wait) not regexp ‘ns|us‘ order by timer_wait desc;