慢SQL分析工具

分析mysql日志的工具:

  • mysqldumpslow
  • mysqlbinlog
  • myprofi
  • mysql-explain-slow-log
  • mysql-log-filter
  • pt-query-digest
  • mysqlsla

介绍mysqldumpslow 和 pt-query-digest

mysqldumpslow

mysql官方自带

经常使用的参数:

-s,是order的顺序

al 平均锁定时间

ar 平均返回记录时间

at 平均查询时间(默认)

c 计数

l 锁定时间

r 返回记录

t 查询时间

-t,是top n的意思,即为返回前面多少条的数据

-g,后边可以写一个正则匹配模式,大小写不敏感的

例子:

mysqldumpslow -t 10 -s t -g “left join” host-slow.log

使用mysqldumpslow的分析结果不会显示具体完整的sql语句,说明:

Count: 358  Time=832.54s (298049s)  Lock=0.00s (0s)  Rows=0.8 (291), ips[ips]@localhost
  select entrance_channel_seq, parking_lot_seq, equipment_gateway_seq,  
  entrance_type, entrance_name, entrance_level, entrance_longitude, entrance_latitude, 
  entrance_address, normal_car_pass_mode, local_vip_car_pass_mode, thirdparty_vip_car_pass_mode, 
  threshold_match_value, card_license_pass_mode, peak_mode, peak_mode_param, constant_open_mode, 
  constant_open_mode_param, no_plate_pass_mode, redlist_pass_mode, blacklist_pass_mode, 
  is_open_card_ticket_machine, voice_open_period, is_charge_group_related, charge_group_code,enable,settlement_type,is_whole_park_in_out,casher_area,
  custom_code,vip_not_in_pass_mode,peak_mode_peroid , peak_mode_auto_arrear ,constant_open_mode_arrear,visitorlist_pass_mode,
no_channel_mode,dynamic_vip_to_normal_mode,
is_normal_car_need_ticket,sharelist_pass_mode,is_coupon_release,
channel_attr,parent_channel_seq,is_self_open_gate
  from tb_entrance_channel
  where entrance_channel_seq = N

主要功能是, 统计不同慢sql的

出现次数(Count),

执行最长时间(Time),

累计总耗费时间(Time),

等待锁的时间(Lock),

发送给客户端的行总数(Rows),

扫描的行总数(Rows),

转载于:https://my.oschina.net/u/1241604/blog/2054551

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值