天天看點

mysqldumpslow用法示例

mysqldumpslow是mysql自帶的用來分析慢查詢的工具

經常使用幾個指令

-s     ORDER what to sort by (al, at, ar, c, l, r, t), ‘at’ is default

-t     NUM just show the top n queries

-g     PATTERN grep: only consider stmts that include this string

-r     Reverse the sort order

-s,是order的順序,主要有

c,t,l,r和ac,at,al,ar,分别是按照query次數,查詢時間,lock的時間和傳回的記錄數來排序,前面加了a的代表平均數

-t,是top n的意思,即為傳回前面多少條的資料

-g,後邊可以寫一個正則比對模式,大小寫不敏感的

下面是一些例子

<a target="_blank" href="http://blog.51cto.com/attachment/201205/173800235.png"></a>

這裡的N代表了數字,不同的數字可以代表為同一句sql語句

以上的意思是這條904條這樣語句,這語句最大執行時間16.44s,一共14861s,最大鎖0.0.5s,一共鎖45s

<a target="_blank" href="http://blog.51cto.com/attachment/201205/173820172.png"></a>

<a target="_blank" href="http://blog.51cto.com/attachment/201205/173911548.png"></a>

還可以使用-g 選項來用正則過濾

<a target="_blank" href="http://blog.51cto.com/attachment/201205/173954891.png"></a>

-s at 代表以平均查詢時間來排序的

      本文轉自hb_fukua  51CTO部落格,原文連結:http://blog.51cto.com/2804976/871691,如需轉載請自行聯系原作者