1、QPS:每秒钟查询数量
show global status like 'Question%';
计算:查询时间总数(Queries)/秒数(seconds)
2、TPS:每秒钟事务数
计算:(提交+回退)时间/秒数【(Com_commit+Com_rollback)/seconds】
show global status like 'Com_commit';
show global status like 'Com_rollback';
3、线程连接数
# 使用最大的连接数
show global status like 'Max_used_connections';
# 线程连接数
show global status like 'Threads%';
4、最大连接数
show variables like 'max_connections';
5、Query Cache
查询缓存用于缓存select查询结果
当下次接收到相同查询请求时,不再执行实际查询处理,而是直接返回结果
适用于大量查询,很少该表表中数据
开启
1、修改 my.cnf
将 query_cache_size 设置为具体的大小,具体多少取决于查询的实际情况,
最好设置为1024的倍数,参考值32M
2、增加一行:query_cache_type = 0/1/2
· 如果设置为0,代表不缓存
· 如果设置为1,将缓存所有的结果,除非你的select语句使用SQL_NO_CACHE
禁用了查询缓存
· 如果设置为2,则只缓存在select语句中通过SQL_CACHE指定需要缓存的查询
6、Query Cache命中率
show status like 'Qcache%';
计算
Qcache_hits / (Qcache_hits + Qcache_inserts) * 100%
7、锁定状态
show global status lik '%lock%';
· Table_locks_waited/Table_locks_immediate 值越大,
代表表锁造成的阻塞越严重
· Innodb_row_lock_waits innodb行锁,太大可能是间隙锁造成的
8、主从延时
查询主从延时时间
show slave status