1. 程式人生 > >mysql 效能統計的一種簡單方式

mysql 效能統計的一種簡單方式

#TPS - Transactions Per Second(每秒傳輸的事物處理個數),這是指伺服器每秒處理的事務數,支援事務的儲存引擎如InnoDB等特有的一個性能指標。
#計算方法:
#TPS = (COM_COMMIT + COM_ROLLBACK)/UPTIME

use information_schema;  
select VARIABLE_VALUE into @num_com from GLOBAL_STATUS where VARIABLE_NAME ='COM_COMMIT';  
select VARIABLE_VALUE into @num_roll from GLOBAL_STATUS where VARIABLE_NAME ='COM_ROLLBACK';  
select VARIABLE_VALUE into @uptime from GLOBAL_STATUS where VARIABLE_NAME ='UPTIME';  
select (@
[email protected]
_roll)/@uptime as TPS; #QPS - Queries Per Second(每秒查詢處理量)同時適用與InnoDB和MyISAM 引擎 #計算方法: #QPS=QUESTIONS/UPTIME use information_schema; select VARIABLE_VALUE into @num_queries from GLOBAL_STATUS where VARIABLE_NAME ='QUESTIONS'; select VARIABLE_VALUE into @uptime from GLOBAL_STATUS where VARIABLE_NAME ='UPTIME'; select @num_queries/@uptime as QPS;