Mysql 慢查詢和慢查詢日誌分析

來源:互聯網
上載者:User

開啟慢查詢記錄功能,接下來,咱們就分析一下慢查詢都有哪些內容:

 

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語句

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.