MYSQL常用的性能指标总结和归纳
发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,(1) QPS(每秒Query量)QPS = Questions(or Queries) / uptimemysql> show global status like 'Question%';mysq
千家信息网最后更新 2026年11月01日MYSQL常用的性能指标总结和归纳(1) QPS(每秒Query量)
QPS = Questions(or Queries) / uptime
mysql> show global status like 'Question%';
mysql> show global status like 'uptime';
(2) TPS(每秒事务量)
TPS = (Com_commit + Com_rollback) / uptime
mysql > show global status like 'Com_commit';
mysql > show global status like 'Com_rollback';
mysql> show global status like 'uptime';
(3)key Buffer 命中率
mysql>show global status like 'key%';
key_buffer_read_hits = (1-key_reads /key_read_requests) * 100%
key_buffer_write_hits = (1-key_writes /key_write_requests) * 100%
(4)InnoDB Buffer命中率
mysql> show status like 'innodb_buffer_pool_read%';
innodb_buffer_read_hits = (1 -innodb_buffer_pool_reads / innodb_buffer_pool_read_requests) * 100%
(5)Query Cache命中率
mysql> show status like 'Qcache%';
Query_cache_hits = (Qcahce_hits /(Qcache_hits + Qcache_inserts )) * 100%;
(6)Table Cache状态量
mysql> show global status like 'open%';
比较 open_tables 与opend_tables值
(7)Thread Cache 命中率
mysql> show global status like'Thread%';
mysql> show global status like'Connections';
Thread_cache_hits = (1 - Threads_created /connections ) * 100%
(8)锁定状态
mysql> show global status like '%lock%';
Table_locks_waited/Table_locks_immediate=0.3% 如果这个比值比较大的话,说明表锁造成的阻塞比较严重
Innodb_row_lock_waits innodb行锁,太大可能是间隙锁造成的
(9)复制延时量
mysql > show slave status
查看Seconds_Behind_Master的值,如果为0,说明没有延迟
(10) Tmp Table 状况(临时表状况)
mysql > show global status like 'Created_tmp%';
Created_tmp_disk_tables/Created_tmp_tables比值最好不要超过10%,如果Created_tmp_tables值比较大,
可能是排序句子过多或者是连接句子不够优化
(11) Binlog Cache 使用状况
mysql > show global status like 'Binlog_cache%';
如果Binlog_cache_disk_use值不为0 ,可能需要调大 binlog_cache_size大小
(12) Innodb_log_waits 量
mysql > show status like'innodb_log_waits';
Innodb_log_waits值不等于0的话,表明 innodblog buffer 因为空间不足而等待
(13)open file and table
mysql> show global status like 'Open_files';
mysql> show global status like 'Open_tables';
(14) 慢查询
开启慢查询:
1).手动执行命令开启:
mysql> set global slow_query_log=on;
mysql> set global long_query_time=1;
2).编辑/etc/my.cnf,在[mysqld]域中添加:
slow_query_log= 1 # 开启慢查询
slow_query_log_file=/data/data/localhost-slow.log # 慢查询日志路径
long_query_time= 1 # 慢查询的时长
(15)全日志
查看全日志:
show global variables like 'general_log';
开启全日志:
set global general_log=on;
注意开启全日志会消耗服务器性能,一般只有在排查问题时才会短暂打开。
QPS = Questions(or Queries) / uptime
mysql> show global status like 'Question%';
mysql> show global status like 'uptime';
(2) TPS(每秒事务量)
TPS = (Com_commit + Com_rollback) / uptime
mysql > show global status like 'Com_commit';
mysql > show global status like 'Com_rollback';
mysql> show global status like 'uptime';
(3)key Buffer 命中率
mysql>show global status like 'key%';
key_buffer_read_hits = (1-key_reads /key_read_requests) * 100%
key_buffer_write_hits = (1-key_writes /key_write_requests) * 100%
(4)InnoDB Buffer命中率
mysql> show status like 'innodb_buffer_pool_read%';
innodb_buffer_read_hits = (1 -innodb_buffer_pool_reads / innodb_buffer_pool_read_requests) * 100%
(5)Query Cache命中率
mysql> show status like 'Qcache%';
Query_cache_hits = (Qcahce_hits /(Qcache_hits + Qcache_inserts )) * 100%;
(6)Table Cache状态量
mysql> show global status like 'open%';
比较 open_tables 与opend_tables值
(7)Thread Cache 命中率
mysql> show global status like'Thread%';
mysql> show global status like'Connections';
Thread_cache_hits = (1 - Threads_created /connections ) * 100%
(8)锁定状态
mysql> show global status like '%lock%';
Table_locks_waited/Table_locks_immediate=0.3% 如果这个比值比较大的话,说明表锁造成的阻塞比较严重
Innodb_row_lock_waits innodb行锁,太大可能是间隙锁造成的
(9)复制延时量
mysql > show slave status
查看Seconds_Behind_Master的值,如果为0,说明没有延迟
(10) Tmp Table 状况(临时表状况)
mysql > show global status like 'Created_tmp%';
Created_tmp_disk_tables/Created_tmp_tables比值最好不要超过10%,如果Created_tmp_tables值比较大,
可能是排序句子过多或者是连接句子不够优化
(11) Binlog Cache 使用状况
mysql > show global status like 'Binlog_cache%';
如果Binlog_cache_disk_use值不为0 ,可能需要调大 binlog_cache_size大小
(12) Innodb_log_waits 量
mysql > show status like'innodb_log_waits';
Innodb_log_waits值不等于0的话,表明 innodblog buffer 因为空间不足而等待
(13)open file and table
mysql> show global status like 'Open_files';
mysql> show global status like 'Open_tables';
(14) 慢查询
开启慢查询:
1).手动执行命令开启:
mysql> set global slow_query_log=on;
mysql> set global long_query_time=1;
2).编辑/etc/my.cnf,在[mysqld]域中添加:
slow_query_log= 1 # 开启慢查询
slow_query_log_file=/data/data/localhost-slow.log # 慢查询日志路径
long_query_time= 1 # 慢查询的时长
(15)全日志
查看全日志:
show global variables like 'general_log';
开启全日志:
set global general_log=on;
注意开启全日志会消耗服务器性能,一般只有在排查问题时才会短暂打开。
日志
查询
命中率
状况
句子
比值
状态
启全
性能
不够
事务
只有
命令
大小
手动
时长
最好
服务器
空间
路径
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网与科技
互联网黑科技
上海睿民互联网科技有限公司
美国互联网保险保险科技
亿策互联网科技
苏州互联网科技贷款公司
奇士达互联网科技
互联网金融科技委员会
互联网科技公司做什么
金融科技和互联网金融
成都互联网科技公司100强
承德科技产业互联网发展
昭通云南众福互联网科技有限公司
恒生互联网科技指数跳水
互联网科技和信息
晋城互联网科技
科技大学互联网
江苏苏星互联网科技有限公司
众联互联网络科技
互联网大会出现的黑科技
互联网科技公司排名
互联网金融 科技金融
赫美联合互联网科技
互联网 科技服务平台
盛创互联网科技有限公司
岳阳华臻互联网科技有限公司
互联网科技圈年度人物
南通创西澳互联网科技有限公司
珠海东科互联网科技有限公司
北京互联网科技类企业分布