PERFORMANCE_SCHEMA 详解
Posted zengkefu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PERFORMANCE_SCHEMA 详解相关的知识,希望对你有一定的参考价值。
mysql 是否支持 PERFORMANCE_SCHEMA 引擎
mysql> SELECT * FROM INFORMATION_SCHEMA.ENGINES ; +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | ENGINE | SUPPORT | COMMENT | TRANSACTIONS | XA | SAVEPOINTS | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ | PERFORMANCE_SCHEMA | YES | Performance Schema | NO | NO | NO | | MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO | | CSV | YES | CSV storage engine | NO | NO | NO | | BLACKHOLE | YES | /dev/null storage engine (anything you write to it disappears) | NO | NO | NO | | MyISAM | YES | MyISAM storage engine | NO | NO | NO | | MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO | | ARCHIVE | YES | Archive storage engine | NO | NO | NO | | InnoDB | DEFAULT | Supports transactions, row-level locking, and foreign keys | YES | YES | YES | | FEDERATED | NO | Federated MySQL storage engine | NULL | NULL | NULL | +--------------------+---------+----------------------------------------------------------------+--------------+------+------------+ 9 rows in set (0.00 sec)
mysql服务器起用 performance_schema
my.cnf文件中 [mysqld] performance_schema=ON
mysql> SHOW VARIABLES LIKE ‘performance_schema‘; +--------------------+-------+ | Variable_name | Value | +--------------------+-------+ | performance_schema | ON | +--------------------+-------+ 1 row in set (0.11 sec)
Performance Schema Instrument命名规则
最上层的instrument 组件
- idle
- stage
- statement
- wait
idle instrument 组件 idle event描述来自:socket_instances.STATE 列: Section 22.9.3.5, “The socket_instances Table”.
stage instrument 组件
组成形式: stage/code_area/stage_name , code_area 一般是sql or myisam。 stage name 一般来自: SHOW PROCESSLIST,如:Sorting result ,Sending data
Statement instrument 组件 statement/abstract/* : 一般都是早期的stage,在抽象sql都还没来得及解析的时候。 statement/com: SQL 命令操作 如:statement/com/Connect statement/sql: SQL语句操作 如:statement/sql/create_db
Wait Instrument 组件 wait/io : IO 等待事件 wait/io/file : 文件IO等待事件。等待文件操作完成的时间如:fwrite().但是物理IO有可能因为缓存的原因调用fwrite时不会写磁盘。 wait/io/socket: socket相关的IO等待 wait/io/table : 表相关的IO等待。一般对于记录rows来说有fetch,insert,update,delete四种操作。 不像其他等待事件,table I/O 还包含了其他的等待事件。
比如:table io可能包含了文件IO和内存IO。因为读取table rows的时候,有可能会去从文件读取数据。 * wait/lock: * wait/lock/table : 表操作的锁等待事件 * wait/synch: * wait/synch/cond :condition就是线程与线程之间的信号。 * wait/synch/mutex : mutex主要用来锁住一块共享资源。 * wait/synch/rwlock : 读写锁
以上是关于PERFORMANCE_SCHEMA 详解的主要内容,如果未能解决你的问题,请参考以下文章
第20天SQL进阶-查询优化- performance_schema系列二:常用配置详解(SQL 小虚竹)