MySQL使用event等待事件進行資料庫效能診斷
首先將performance_schema這個資料庫下的需要進行跟蹤的指標開啟:
update setup_consumers set enabled='yes' where name like '%wait%';
select * from setup_consumers where name like '%wait%';
建立一個檢視方便後續查詢:
create view sys.test_waits as select sum(timer_wait) as timer_wait, sum(number_of_bytes) as numer_of_bytes, event_name, operation from performance_schema.events_waits_current where event_name != 'idle'
group by event_name, operation;
查詢:
select sys.format_time(timer_wait), sys.format_bytes(numer_of_bytes), event_name, operation from sys.test_waits order by timer_wait;
當我執行壓測時效果如下:
mysql> select sys.format_time(timer_wait), sys.format_bytes(numer_of_bytes), event_name, operation from sys.test_waits order by timer_wait;
+-----------------------------+----------------------------------+--------------------------------------+---------------+
| sys.format_time(timer_wait) | sys.format_bytes(numer_of_bytes) | event_name | operation |
+-----------------------------+----------------------------------+--------------------------------------+---------------+
| 1.57 us | NULL | wait/lock/table/sql/handler | read external |
| 2.02 us | 8.00 KiB | wait/io/file/sql/binlog | read |
| 2.55 us | 512 bytes | wait/io/file/innodb/innodb_log_file | write |
| 9.19 us | 16.00 KiB | wait/io/file/innodb/innodb_data_file | write |
| 33.78 us | 1 bytes | wait/io/table/sql/handler | delete |
| 104.83 us | 128.00 KiB | wait/io/file/innodb/innodb_data_file | read |
| 2.35 ms | NULL | wait/io/file/innodb/innodb_log_file | sync |
| 6.45 ms | NULL | wait/io/file/innodb/innodb_data_file | sync |
| 13.69 ms | 1 bytes | wait/io/table/sql/handler | fetch |
+-----------------------------+----------------------------------+--------------------------------------+---------------+
9 rows in set (0.01 sec)
mysql> select sys.format_time(timer_wait), sys.format_bytes(numer_of_bytes), event_name, operation from sys.test_waits order by timer_wait;
+-----------------------------+----------------------------------+--------------------------------------+-----------+
| sys.format_time(timer_wait) | sys.format_bytes(numer_of_bytes) | event_name | operation |
+-----------------------------+----------------------------------+--------------------------------------+-----------+
| 2.12 us | 8.00 KiB | wait/io/file/sql/binlog | read |
| 44.06 us | 16.00 KiB | wait/io/file/innodb/innodb_data_file | write |
| 53.48 us | 8.00 KiB | wait/io/file/innodb/innodb_log_file | write |
| 140.21 us | 128.00 KiB | wait/io/file/innodb/innodb_data_file | read |
| 2.19 ms | NULL | wait/io/file/innodb/innodb_log_file | sync |
| 3.6 ms | NULL | wait/io/file/innodb/innodb_data_file | sync |
+-----------------------------+----------------------------------+--------------------------------------+-----------+
摘自: 《千金良方:MySQL效能優化金字塔法則》
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8520577/viewspace-2849947/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 等待事件效能診斷方法事件
- mysql資料庫效能診斷MySql資料庫
- 基於等待事件的效能診斷事件
- 基於等待事件的效能診斷(轉)事件
- 使用SQL_TRACE進行資料庫診斷SQL資料庫
- 深入淺出等待事件和效能診斷01事件
- 深入淺出等待事件和效能診斷02事件
- 深入淺出等待事件和效能診斷04事件
- 深入淺出等待事件和效能診斷05事件
- 使用SQL_TRACE進行資料庫診斷(轉)SQL資料庫
- 使用SQL_TRACE進行資料庫診斷(1)SQL資料庫
- 使用SQL_TRACE進行資料庫診斷(2)SQL資料庫
- 使用SQL_TRACE進行資料庫診斷(zt)SQL資料庫
- 等待事件快速定位診斷事件
- 轉載:使用SQL_TRACE進行資料庫診斷SQL資料庫
- 使用SQL_TRACE進行資料庫診斷(轉載)SQL資料庫
- 使用awr來診斷資料庫效能問題資料庫
- 【DB】使用SQL_TRACE進行資料庫診斷跟蹤SQL資料庫
- 使用SQL_TRACE /10046進行資料庫診斷SQL資料庫
- 深入淺出等待事件和效能診斷記載03事件
- zt_oracle診斷事件event列表Oracle事件
- 使用Dstat來進行Linux綜合效能診斷Linux
- 如何診斷等待事件 enq: HW - contention事件ENQ
- 轉_診斷latch:shared pool等待事件事件
- latch free 等待事件的診斷語句事件
- 如何使用AWR報告來診斷資料庫效能問題資料庫
- 【event messages】使用PL/SQL獲取Oracle診斷事件列表SQLOracle事件
- Part II 診斷和優化資料庫效能優化資料庫
- 自管理的資料庫:自動效能診斷資料庫
- MySQL資料庫診斷:InnoDB關機問題MySql資料庫
- [資料庫] Navicat for MySQL事件Event實現資料每日定期操作資料庫MySql事件
- 【Oracle】資料庫hang 診斷Oracle資料庫
- Oracle配置資料庫診斷Oracle資料庫
- MySQL效能診斷與調優MySql
- 利用errorstack事件進行錯誤跟蹤和診斷Error事件
- db file async I/O submit等待事件的故障診斷MIT事件
- 索引分裂造成的index contention等待事件的診斷索引Index事件
- dbms_addm執行oracle資料庫診斷Oracle資料庫