浅谈MySQL慢查询日志及microslow patch(msl patch)

开发者福利!热门AI工具限时免费用 购周边即赠Coding Plan Lite,Claude Code、Cursor等20+工具畅享,效率翻倍! 阅读详情

mysql(包括所有5.*系列,5.1.21之前)的慢查询日志默认是以秒为单位的,可以通过set [session|global] long_query_time=1这个最低也就是可以设置到1秒,对于0.5,0.005之类就无能为力了,这时候可以有microslow patch(msl patch)补丁来完成这一工作,这个功能的好处自然不言而喻.

在mysql5.1.21及以后版本可以通过set [session|global] long_query_time=0.01等来设置记录0.01秒以上的sql语句.

在5.1.6之后系列产品中还有--log-output=[FILE|TABLE|NONE]特性,这个是选择general_log和slow_log的存储方式,文件,数据表,还是不记录,5.1.6-5.1.20默认是数据表(mysql.slow_log表),其余默认是文件.

--log-queries-not-using-indexes也是5.1的新选项,可以没有使用index的sql语句记录到慢查询日志中

--log-slow-admin-statements该命令选项可以将OPTIMIZE TABLE, ANALYZE TABLE, 以及ALTER TABLE 等管理操作写道慢查询日志中.

在5.0系列产品可以通过安装microslow patch(msl patch)来改进慢查询日志.

这些选项可以加在启动命令上也可以记录在my.cnf里面

至于查看日志,可以直接查看也可以使用工具,对于比较多的日志还是日志方便些.常见的工具有mysql自带的mysqldumpslow以及第三方工具mysqlsla等.

msl patch是通过修改mysql源代码的方式来增强mysql的功能,所以只能是源码安装才可以扩展这个功能,其在www.mysqlperformanceblog.com上有详细介绍(其实英语很简单,嘿嘿)

有篇文章详细说明了microslow patch的安装和使用摘几个选项放在这方便以后查看

Configuration

There are several parameters related to slow log you can set with patch applied. All filter-type options work in conjunction meaning that in order for query to be logged it must match long_query_time AND min_examined_row_limit AND log_slow_filter.


log-slow-queries[=name]

Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.

This is the most important one as it enables the logging. If you don’t specify it in my.cnf file, the remaining part of the configuration will not matter, because the log file won’t be created. This is also the only option which you cannot change at runtime from MySQL console wit SET or SET GLOBAL command.

log_slow_filter=name

Log only the queries that followed certain execution plan. Multiple flags allowed in a comma-separated string. [qc_miss, full_scan, full_join, tmp_table, tmp_table_on_disk, filesort, filesort_on_disk]

It allows you to filter queries logged by execution plan. For example to log only queries doing full table scans you would need to set this to “full_scan”, while in order to get only those which use on-disk temporary storage for intermediate results “tmp_table_on_disk,filesort_on_disk” would be a proper flags set. To clear the filter just assign an empty string “” to this option.

Note: you should put double quotes around the entire string of comma-separated flags.

Can be changed at run time with both SET SESSION and SET GLOBAL.

log_slow_rate_limit=#

Rate limit statement writes to slow log to only those from every (1/log_slow_rate_limit) session.

With high traffic coming to your database, the slow logging may consume a lot of IO bandwidth and the file may grow huge very quickly when logging all the queries. This parameter allows you to get the full sessions logged while doing it only for every n-th of them thus limiting the number of writes to the log.

Note: this feature will fail to work well if your application uses some kind of connection pooling. Rate limiting is disabled for the replication thread.

Can be changed at run time with both SET SESSION and SET GLOBAL.

log_slow_verbosity=name

Choose how verbose the messages to your slow log will be. Multiple flags allowed in a comma-separated string. [microtime, query_plan, innodb]

msl patch currently can log three types of information: query timings, execution plan details and InnoDB engine per-query statistics. With this option you may choose which of those you want to have in your slow log. For example to have microsecond query timing and InnoDB statistics you would need to set this option to “microtime,innodb”.

Note: You should put double quotes around the entire string of comma-separated flags. Currently “microtime” is mandatory meaning you cannot disable it. “innodb” is only available with the patch supporting that feature.

Can be changed at run time with both SET SESSION and SET GLOBAL.

long_query_time=#

Log all queries that have taken more than long_query_time microseconds to execute to file.

This option is standard MySQL, however after you apply the patch, it will no longer take time in seconds. Instead it will want you to specify the number of microseconds.

Can be changed at run time with both SET SESSION and SET GLOBAL.

min_examined_row_limit=#

Don’t log queries which examine less than min_examined_row_limit rows to file.

If you are not interested in queries which scan no more than N rows, you can set this to the desired value.

Can be changed at run time with both SET SESSION and SET GLOBAL.

探索者破解 按照解压后文件自己破解,破解后即可正常安装使用 立即下载

相关推荐

Origin pro 2017 PatchOriginPro.exe

选择使用序列号安装版本 Origin 2017 eva或OriginPro 2017后,将PatchOriginPro.exe拷到安装路径里,双击运行,出现successful表示破解成功。

关于Navicat for MySQL第一次破解就出现Path unsuccessfully or already

安装没有什么注意的,点点next就行,注意一下安装路径;破解的话,把PatchNavicat粘贴到Navicat for MySQL安装的目录下,双击运行,出来的窗口点打开就行,如果第一次破解就出现Path unsuccessfully or already的话,可能是因为你之前安装了最新版,把最新版卸载掉就好了...

Super_Allen的博客 2万+

一、qt下载与安装

qt与qtcreator 的区别与联系 1、QT Creator只是一个集成的编译器,用于将源代码编译成可执行程序。 QT 是跨平台C++图形用户界面应用程序开发框架,可以简单理解成是一个开发包。 2、Qt是完全面向对象的,很容易扩展,并且允许真正地组件编程。 QT Creator 跨平台的 Qt IDE,Qt Creator 是 Qt 被 Nokia 收购后推出的一款新的轻量级集 ...

yiye_pianzhou的博客 2200

Origin Pro2017使用PatchOriginPro.exe破解提示Patch unsuccessfully or already

0.直接提示Patch unsuccessfully or already 1.右键单击PatchOriginPro.exe,选择管理员身份运行,提示Patch successfully,补丁安装成功(4修订) 2.以点带面,今后配置软件出现破解不成功的情况,尝试以管理员身份运行

qq_31420401的博客 4万+

[解决]Yosemite 中 Patch 破解程序不能用的问题

在升级Yosemite 后发现有些以前的破解程序不能用了,尤其是一些 patch 程序,比如软件仓库里的 iDocument .  会报以下的错误  This patch seems to be corrupted. Please make sure you get your patchers from a trusted source.  If you believe you did, t

Dawnworld 3653

mysql 8.0安装msl_浅谈mysql慢查询msl补丁(microslow patch

mysql(包括所有5.*系列,5.1.21之前)慢查询日志默认是以秒为单位的,可以通过set [session|global] long_query_time=1这个最低也就是可以设置到1秒,对于0.5,0.005之类就无能为力了,这时候可以有microslow patch(msl patch)补丁来完成这一工作,这个功能的好处自然不言而喻.在mysql5.1.21及以后版本可以通过 set ...

weixin_39673037的博客 223

浅谈mysql慢查询msl补丁(microslow patch

mysql(包括所有5.*系列,5.1.21之前)慢查询日志默认是以秒为单位的,可以通过set [session|global] long_query_time=1这个最低也就是可以设置到1秒,对于0.5,0.005之类就无能为力了,这时候可以有microslow patch(msl patch)补丁来完成这一工作,这个功能的好处自然不言而喻.在m...

weixin_34239169的博客 124

Updated msl (microslow) patch, installation walk-through!

#转载地址:http://www.mysqlperformanceblog.com/2008/04/20/updated-msl-microslow-patch-installation-walk-through/   For a couple of months there have been no updates to our msl patch, however recently I m...

zhang_ly520的专栏 219

如何轻松地安装和破解navicat for mysql

安装步骤如下:点击打开链接

张亚萍的专栏 1218

关于激活navicat11失败

失败原因:在联网的情况下打开过。所以需要把原来的卸载,再装一遍。切记别联网打开!!! 更高版本失败的原因应该是相同的可以借鉴本文章。破解过程:https://www.cnblogs.com/miantiaoandrew/p/7912469.html。...

wlb1012768230的博客 6872

Classpath entry *.jar will not be exported or published类警告处理方法

在eclipse的web工程中,常会遇见 Description Resource Path Location Type Classpath entry *.jar will not be exported or published. Runtime ClassNotFoundExceptions may result.   此类错误,错误提示jar包不会导出或发布 错误产生原因是

Snowfish的博客 6009

Python自动化临时文件管理系统设计与实现

临时文件管理是软件开发与系统运维中的基础问题,涉及文件系统操作、资源生命周期管理等多个技术领域。通过Python实现自动化管理系统,可以基于SQLite记录元数据,利用tempfile标准库确保线程安全,实现创建、使用、清理的全周期管理。该系统采用智能清理策略(按时间/空间阈值触发),支持版本控制和跨进程文件锁,有效解决临时文件导致的磁盘爆满、版本冲突等工程痛点。典型应用场景包括CI/CD流水线、数据分析管道等需要严格管理临时资源的场景,相比传统手动管理方式可减少87%的存储浪费和100%的文件冲突。

weixin_34236869的博客 472

MySQL的表锁问题()——InnoDB表锁问题

首先补充下MySQL的表锁问题()没讲到的系统可以通过设置max_write_lock_count参数来控制写的优先级,当一个表的读锁达到这个数的时候,MySQL会暂时的,降低写的优先级.MySQL尽量少用一些看似精妙但复杂的语句,因为你复杂可能导致给表加的读锁时间就长,会导致写的操作无法进行. innodb和MyISAM最大的区别在于innodb支持事务处理和行级锁,行级锁带来的好处是可以支

i am a dummy 1万+

MySQL的表锁问题()

  在mysql手册里面有一段描述关于lock tables的语法的. LOCK TABLES     tbl_name [AS alias] {READ [LOCAL] | [LOW_PRIORITY] WRITE}     [, tbl_name [AS alias] {READ [LOCAL] | [LOW_PRIORITY] WRITE

i am a dummy 6350

innodb表文件直接复制出现不能启动mysqlmysql不支持innodb的问题

今天偷懒直接复制了一个innodb表文件,来复制数据库,首先我知道table.frm是变结构文件,拷过去,还有个ibdata1,主要是表数据文件,还有ib_logfile0和ib_logfile1文件日志文件,有趣是新建数据库,想也没想就拷过去覆盖了.然后开启mysql失败,赶紧查看日志,提示 InnoDB: Error: log file ./ib_logfile0 is of differe

i am a dummy 5744
上一篇: Linux下初步配置Apache+Subversion
下一篇: MySQL的表锁问题(一)
skyoverflow
博客等级 码龄18年 17粉丝 47原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值