日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

suse查看mysql内存使用情况_MySQL 慢查询日志(Slow Query Log)

發布時間:2024/9/27 数据库 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 suse查看mysql内存使用情况_MySQL 慢查询日志(Slow Query Log) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

4、格式化慢查詢日志

結構化慢查詢日志就是把慢查詢日志中的重要信息按照便于閱讀以及按照特定的排序方式來提取SQL。

這種方式有點類似于Oracle中有個tkprof來格式化oracle的trace文件。

對于前面的慢查詢日志我們使用MySQLdumpslow來提取如下:

SUSE11b:~ # mysqldumpslow -s at,al /var/lib/mysql/suse11b-slow.log

Reading mysql slow query log from /var/lib/mysql/suse11b-slow.log

Count: 4? Time=16.87s (67s)? Lock=0.00s (0s)? Rows=0.0 (0), root[root]@localhost

insert into tb_slow select * from tb_slow

Count: 1? Time=0.20s (0s)? Lock=0.00s (0s)? Rows=1.0 (1), root[root]@localhost

select count(*) from tb_slow

Count: 1? Time=1.57s (1s)? Lock=0.00s (0s)? Rows=83.0 (83), root[root]@localhost

select table_schema,table_name,count(*) from tb_slow

group by table_schema,table_name order by N,N

#以下是按照最大耗用時間排最后,只顯示2條的方式格式化日志文件

suse11b:~ # mysqldumpslow -r -t 2 /var/lib/mysql/suse11b-slow.log

Reading mysql slow query log from /var/lib/mysql/suse11b-slow.log

Count: 1? Time=1.57s (1s)? Lock=0.00s (0s)? Rows=83.0 (83), root[root]@localhost

select table_schema,table_name,count(*) from tb_slow

group by table_schema,table_name order by N,N

Count: 4? Time=16.87s (67s)? Lock=0.00s (0s)? Rows=0.0 (0), root[root]@localhost

insert into tb_slow select * from tb_slow

#獲取mysqldumpslow的幫助信息

suse11b:~ # mysqldumpslow --help

Usage: mysqldumpslow [ OPTS... ] [ LOGS... ]

Parse and summarize the MySQL slow query log. Options are

--verbose? ? verbose

--debug? ? ? debug

--help? ? ? write this text to standard output

-v? ? ? ? ? verbose

-d? ? ? ? ? debug

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

al: average lock time

ar: average rows sent

at: average query time

c: count? ? ? ? #query的次數

l: lock time

r: rows sent? ? #返回的記錄數

t: query time

-r? ? ? ? ? reverse the sort order (largest last instead of first)

-t NUM? ? ? just show the top n queries

-a? ? ? ? ? don't abstract all numbers to N and strings to 'S'

-n NUM? ? ? abstract numbers with at least n digits within names

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

-h HOSTNAME? hostname of db server for *-slow.log filename (can be wildcard),

default is '*', i.e. match all

-i NAME? ? ? name of server instance (if using mysql.server startup script)

-l? ? ? ? ? don't subtract lock time from total time

總結

以上是生活随笔為你收集整理的suse查看mysql内存使用情况_MySQL 慢查询日志(Slow Query Log)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。