像这样:
# Query_time: 1.310542 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use data_xxx;
SET timestamp=1441008434;
commit;
# Query_time: 1.310542 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
use data_xxx;
SET timestamp=1441008434;
commit;
这是我机器上的慢日志:C:\Program Files\MySQL\MySQL Server 5.6\bin\mysqld.exe, Version: 5.6.25-log (MySQL Community Server (GPL)). started with:
TCP Port: 3306, Named Pipe: (null)
Time Id Command Argument
# Time: 150825 15:57:07
# User@Host: root[root] @ [192.168.100.50] Id: 62
# Query_time: 101.961779 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 6479872
use world;
SET timestamp=1440489427;
update tb set idd = id;
# Time: 150825 15:58:41
# User@Host: root[root] @ [192.168.100.50] Id: 62
# Query_time: 48.266485 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 6479872
SET timestamp=1440489521;
update tb set idd = id;
# Time: 150825 16:00:00
# User@Host: root[root] @ [192.168.100.50] Id: 62
# Query_time: 54.506496 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 6479872
SET timestamp=1440489600;
update tb set idd = id;
# Time: 150825 16:01:57
# User@Host: root[root] @ [192.168.100.50] Id: 65
# Query_time: 38.110867 Lock_time: 0.000000 Rows_sent: 501 Rows_examined: 6479872
SET timestamp=1440489717;
select * from tb where idd >= 1000 and idd <= 1500;
另外,我看你的 # Query_time: 1.310542 也就是,你设置的 long_query_time 可能是1秒,这个有必要吗?如果你运行了好多语句,虽然每条数据都很快,但是在最后commit的时候,由于是大批量数据的提交,就会导致commit很慢,就会被记录下来
我觉得,楼主可以修改一下参数设置,我的是mysql默认的是10秒,然后设置为3秒:mysql> show variables like '%long_query_time%';
+-----------------+-----------+
| Variable_name | Value |
+-----------------+-----------+
| long_query_time | 10.000000 |
+-----------------+-----------+
1 row in set (0.01 sec)mysql> set global long_query_time = 3;
Query OK, 0 rows affected (0.04 sec)mysql> select @@global.long_query_time;
+--------------------------+
| @@global.long_query_time |
+--------------------------+
| 3.000000 |
+--------------------------+
1 row in set (0.02 sec)mysql>
是的,不同的应用环境,不同的需求方式,没有一定的准则