Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1994419
  • 博文数量: 176
  • 博客积分: 1857
  • 博客等级: 上尉
  • 技术积分: 2729
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-14 22:55
个人简介

吾生有涯,而知无涯,适当止学.循序渐进,步步提升 Talk is cheap, show me the code.

文章分类

全部博文(176)

文章存档

2019年(1)

2018年(14)

2017年(20)

2016年(31)

2015年(15)

2014年(5)

2013年(10)

2012年(80)

分类: Mysql/postgreSQL

2012-07-02 14:35:10

 Mysql_slow_log_parser.txt 
txt脚本的名字要改名为pl

使用方式:

./Mysql_slow_log_parser.pl /data/mysqldata/3306/data/zsd-slow.log

之前zsd-slow.log的内容:

/usr/local/mysql55/bin/mysqld, Version: 5.5.25-log (Source distribution). started with:
Tcp port: 3306  Unix socket: /data/mysqldata/3306/mysql.sock
Time                 Id Command    Argument
# Time: 120702 12:10:27
# User@Host: root[root] @ localhost []
# Query_time: 1.558936  Lock_time: 0.000077 Rows_sent: 0  Rows_examined: 262144
use test;
SET timestamp=1341245427;
insert into t1 select * From t1;
# Time: 120702 12:10:31
# User@Host: root[root] @ localhost []
# Query_time: 3.077640  Lock_time: 0.000083 Rows_sent: 0  Rows_examined: 524288
SET timestamp=1341245431;
insert into t1 select * From t1;
# Time: 120702 12:10:38
# User@Host: root[root] @ localhost []
# Query_time: 6.081219  Lock_time: 0.000075 Rows_sent: 0  Rows_examined: 1048576
SET timestamp=1341245438;
insert into t1 select * From t1;
# Time: 120702 12:10:58
# User@Host: root[root] @ localhost []
# Query_time: 2.402953  Lock_time: 0.000152 Rows_sent: 1048576  Rows_examined: 2097152
SET timestamp=1341245458;
select * from t1 order by name;
# Time: 120702 12:13:18
# User@Host: root[root] @ localhost []
# Query_time: 13.259154  Lock_time: 0.000144 Rows_sent: 0  Rows_examined: 2097152
SET timestamp=1341245598;
insert into t1 select * From t1;
# Time: 120702 12:16:03
# User@Host: root[root] @ localhost []
# Query_time: 25.903786  Lock_time: 0.000089 Rows_sent: 0  Rows_examined: 4194304
SET timestamp=1341245763;
insert into t1 select * From t1;

之后输出的内容:

 Starting...
### 3 Queries
### Total time: 22.418013, Average time: 7.472671
### Taking 3.077640 , 6.081219 , 13.259154  seconds to complete
### Rows analyzed 524288, 1048576 and 2097152
SET timestamp=XXX;
insert into tXXX select * From tXXX;

SET timestamp=1341245598;
insert into t1 select * From t1;


### 1 Query
### Total time: 2.402953, Average time: 2.402953
### Taking 2.402953  seconds to complete
### Rows analyzed 2097152
SET timestamp=XXX;
select * from tXXX order by name;

SET timestamp=1341245458;
select * from t1 order by name;


### 1 Query
### Total time: 1.558936, Average time: 1.558936
### Taking 1.558936  seconds to complete
### Rows analyzed 262144
use test;
SET timestamp=XXX;
insert into tXXX select * From tXXX;

use test;
SET timestamp=1341245427;
insert into t1 select * From t1;


这个脚本可以很好的汇总和分析慢查询日志,晚上写个定时的脚本,输出发送邮件给自己,可以很好的查看,Mysql服务器慢查询的问题。
阅读(4001) | 评论(0) | 转发(1) |
0

上一篇:没有了

下一篇:Perl源码安装

给主人留下些什么吧!~~