- 论坛徽章:
- 0
|
my.cnf相关配置如下:
log-slow-queries=/usr/local/mysql/varslowquery.log
long_query_time=5
根据文档
log-slow-queries 设置把日志写在那里
long_query_time=5中的5表示查询超过五秒才记录.
不过,检查日志,却发现很多不超过5s的查询都会记录下来,日志如下:
# User@Host: root[root] @ localhost []
# Query_time: 0.000094 Lock_time: 0.000024 Rows_sent: 0 Rows_examined: 0
SET timestamp=1260514025;
UPDATE gamesession SET session_expires = '1260515825', session_data = 'ljuser|s:13:"chenqingji008";task|s:2:"52";' WHERE session_id = '79bfdd9840bdf4cdb19d19ff90dc0643';
# User@Host: root[root] @ localhost []
# Query_time: 0.000046 Lock_time: 0.000014 Rows_sent: 0 Rows_examined: 0
SET timestamp=1260514025;
DELETE FROM gamesession WHERE session_expires < 1260514025;
# Time: 091211 14:47:09
# User@Host: root[root] @ localhost []
# Query_time: 0.000091 Lock_time: 0.000028 Rows_sent: 1 Rows_examined: 8
SET timestamp=1260514029;
SELECT session_data AS d FROM gamesession WHERE session_id = 'c5b080c0c743f6474e703bdcd30c6b74' AND session_expires >1260514029;
# User@Host: root[root] @ localhost []
# Query_time: 0.000083 Lock_time: 0.000021 Rows_sent: 1 Rows_examined: 8
SET timestamp=1260514029;
SELECT * FROM gamesession WHERE session_id = 'c5b080c0c743f6474e703bdcd30c6b74';
# User@Host: root[root] @ localhost []
# Query_time: 0.000078 Lock_time: 0.000019 Rows_sent: 0 Rows_examined: 0
SET timestamp=1260514029;
UPDATE gamesession SET session_expires = '1260515829', session_data = 'zzyljuser|s:6:"gwycbb";' WHERE session_id = 'c5b080c0c743f6474e703bdcd30c6b74';
# User@Host: root[root] @ localhost []
# Query_time: 0.000044 Lock_time: 0.000013 Rows_sent: 0 Rows_examined: 0
SET timestamp=1260514029;
DELETE FROM gamesession WHERE session_expires < 1260514029;
有资料说要看log-queries-not-using-indexes 值,如下:
mysql> show variables like'%using%' ;
+-------------------------------+-------+
| Variable_name | Value |
+-------------------------------+-------+
| log_queries_not_using_indexes | ON |
+-------------------------------+-------+
1 row in set (0.00 sec)
不知道为什么,请不吝指教! |
|