【工作经历:阿里巴巴搜索技术研发中心QA ,百度新产品测试部QA】
【领域:测试分析,自动化测试,性能测试,安全测试 】
【个人定位:高级测试工程师+培训师+领域产品专家】
mysql的微秒补丁
上一篇 /
下一篇 2012-02-10 15:55:06
/ 个人分类:性能测试
最近做一个项目的
性能测试,是涉及算法相关的。整个项目由c++开发。读文件,写
数据库,查询网络接口,写数据。蛮简单。
不过发现了2个性能问题。解决过程中,折腾了不少,其中用到了一个
mysql的性能排查方法,在此标注下,以备参考。
mysql在性能profile的过程中,有很多的方法和工具,比较靠谱的一个方法,就是打开slow query log。
但是slow log在5.1之前的版本,只能精确到1m级别。这个很鸡肋,不能满足性能profile的需要。
所以需要进行进一步的精确。
国外已经有人研究出了对应的方法。对mysql的代码进行修改,并做了一个补丁。
连接参考如下
用法很简单
patch patch.diff
./configure
make
make install
安装并启动mysql后,设置long_query_time=0 就可以开启slow query的微秒记录功能了。
这个方法,是国外2006年搞定的,已经6年了。。汗。
google之竟然发现被引用了无数次。
下一步开始考虑mysql的研究
学习了,发现mysql的性能问题还是蛮多的,mysql的各种机制需要深挖下。
附上mysql官方的支持情况,有点无语。。
Summary of Official Support
v4.0, 4.1, 5.0: not supported; long_query_time is limited to a resolution of 1 to 10 seconds.
v5.1 up to and including 5.1.20: not supported; long_query_time is limited to a resolution of 1 to 10 seconds.
5.1.21+: for the value of long_query_time "the minimum is 0, and a resolution of microseconds is supported when logging to a file. However, the microseconds part is ignored and only integer values are written when logging to tables." (MySQL :: MySQL 5.1 Reference Manual :: 5.2.5 The Slow Query Log)
6.0 up to and including 6.0.3: not supported; long_query_time is limited to a resolution of 1 to 10 seconds.
6.0.4+: for the value of long_query_time "the minimum is 0, and a resolution of microseconds is supported when logging to a file. However, the microseconds part is ignored and only integer values are written when logging to tables." (MySQL :: MySQL 6.0 Reference Manual :: 5.2.5 The Slow Query Log)
收藏
举报
TAG: