-
Notifications
You must be signed in to change notification settings - Fork 55
第4章 performance_schema初相识
xiaoboluo768 edited this page Jun 18, 2020
·
3 revisions
mysql> SELECT * FROM INFORMATION_SCHEMA.ENGINES WHERE ENGINE ='PERFORMANCE_SCHEMA';
......
1 row in set (0.00 sec)
mysql> show engines;
......
9 rows in set (0.00 sec)
[mysqld]
performance_schema = ON # 注意:该参数为只读参数,需要在实例启动之前设置才生效
mysql> show variables like 'performance_schema';
......
1 row in set (0.00 sec)
mysql>SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='performance_ schema' and engine='performance_schema';
......
87 rows in set (0.00 sec)
mysql> use performance_schema
Database changed
mysql> show tables from performance_schema;
......
87 rows in set (0.00 sec)
mysql> show tables like 'events_statement%';
......
11 rows in set (0.00 sec)
mysql> show tables like 'events_wait%';
......
12 rows in set (0.01 sec)
mysql> show tables like 'events_stage%';
......
8 rows in set (0.00 sec)
mysql> show tables like 'events_transaction%';
......
8 rows in set (0.00 sec)
mysql> show tables like '%file%';
......
3 rows in set (0.01 sec)
mysql> show tables like '%memory%';
......
5 rows in set (0.01 sec)
mysql> show tables like '%setup%';
......
5 rows in set (0.00 sec)
mysql> UPDATE setup_instruments SET ENABLED = 'YES', TIMED = 'YES' where name like 'wait%';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 323 Changed: 0 Warnings: 0
mysql> UPDATE setup_consumers SET ENABLED = 'YES' where name like '%wait%';
Query OK, 3 rows affected (0.04 sec)
Rows matched: 3 Changed: 3 Warnings: 0
mysql> SELECT * FROM events_waits_current limit 1\G
......
1 row in set (0.02 sec)
# 该事件信息表示线程ID为4的线程正在等待InnoDB存储引擎的log_sys_mutex锁,这是InnoDB存储引擎的一个互斥锁,等待时间为65664皮秒(*_ID列表示事件来自哪个线程、事件编号是多少;EVENT_NAME表示检测到的具体内容;SOURCE表示这个检测代码在哪个源文件中以及行号;计时器字段TIMER_START、TIMER_END、TIMER_WAIT分别表示该事件的开始时间、结束时间和总的花费时间,如果该事件正在运行而没有结束,那么TIMER_END和TIMER_WAIT的值显示为NULL。注:计时器统计的值是近似值,并不是完全精确的)
mysql> SELECT THREAD_ID, EVENT_ID,EVENT_NAME,TIMER_WAIT FROM events_waits_history ORDER BY THREAD_ID limit 21;
......
21 rows in set (0.00 sec)
mysql> SELECT EVENT_NAME, COUNT_STAR FROM events_waits_summary_global_by_event_name ORDER BY COUNT_STAR DESC LIMIT 10;
......
mysql> SELECT EVENT_NAME, SUM_TIMER_WAIT FROM events_waits_summary_global_by_event_name ORDER BY SUM_TIMER_WAIT DESC LIMIT 10;
......
# 这些结果表明,THR_LOCK_malloc互斥事件是最热的。注:THR_LOCK_malloc互斥事件仅在DEBUG版本中存在,在GA版本中不存在
mysql> SELECT * FROM file_instances limit 20;
......
20 rows in set (0.00 sec)
上一篇:第3章 MySQL体系结构 | 下一篇:第5章 performance_schema配置详解
-
本 WIKI 包含了《千金良方--MySQL 性能优化金字塔法则》一书的代码段加粗命令行命令和SQL语句文本、以及4个附录内容,其中:
- 代码段和高清图单独整理为一个系列文档,如下:
- 每个附录都各自整理成了一个小系列文档,如下:
-
《千金良方--MySQL 性能优化金字塔法则》 一书的作者信息如下:
- 李春、罗小波、董红禹
-
联系人QQ:309969177
-
提示:
-
郑重声明:本WIKI仓库中的资料为电子工业出版社与本书的三位作者共同授权开源,为了在方便大家的同时,避免不必要的纠葛,任何商业与非商业的引用、转载,麻烦大家注明出处,谢谢配合!