開啟慢查詢記錄功能,接下來,咱們就分析一下慢查詢都有哪些內容:
SELECT COUNT(DISTINCT a.Name) FROM cp_paycard AS a LEFT JOIN cp_reservation AS b ON a.UID=b.UID WHERE a.Type=2 AND b.CpParkID='7159' AND b.BusinessType IN (5,8) AND ValidEndDate>'2013-07-05 23:59:59';
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 0 Lock_time: 0 Rows_sent: 1 Rows_examined: 275
D:\AppServ\MySQL\bin\mysqld-nt, Version: 5.0.45-community-nt-log (MySQL Community Edition (GPL)). started with:
TCP Port: 3306, Named Pipe: (null)
Time Id Command Argument
# Time: 130705 11:17:32
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 0 Lock_time: 0 Rows_sent: 1 Rows_examined: 6
use 51park;
SELECT nextrun FROM uchome_cron WHERE available>'0' ORDER BY nextrun LIMIT 1;
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 0 Lock_time: 0 Rows_sent: 144 Rows_examined: 144
SELECT * FROM uchome_config;
# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 0 Lock_time: 0 Rows_sent: 1 Rows_examined: 275
【說明】
queries total: 總查詢次數 unique:去重後的sql數量
sorted by : 輸出報表的內容排序
最重大的慢sql統計資訊, 包括 平均執行時間, 等待鎖時間, 結果行的總數, 掃描的行總數.
Count, sql的執行次數及佔總的slow log數量的百分比.
Time, 執行時間, 包括總時間, 平均時間, 最小, 最大時間, 時間佔到總慢sql時間的百分比.
95% of Time, 去除最快和最慢的sql, 覆蓋率佔95%的sql的執行時間.
Lock Time, 等待鎖的時間.
95% of Lock , 95%的慢sql等待鎖時間.
Rows sent, 結果行統計數量, 包括平均, 最小, 最大數量.
Rows examined, 掃描的行數量.
Database, 屬於哪個資料庫
Users, 哪個使用者,IP, 佔到所有使用者執行的sql百分比
Query abstract, 抽象後的sql語句
Query sample, sql語句