我在我的数据库服务器上设置了MySQL慢查询日志,并将长查询时间设置为5.
只需检查日志及其日志查询,只需几毫秒。任何人都知道为什么会这样?这是一些日志。
I am using mysql sloq query log and set the following line in my.cnf file:
slow_query_log=1
long_query_time=5
log-output=FILE
log-queries-not-using-indexes
but my log file show like :
# User@Host: root[root] @ localhost []
# Query_time: 0.077108 Lock_time: 0.000042 Rows_sent: 0 Rows_examined: 292
SET timestamp=1389868398;
UPDATE `cp_sessions` SET `last_activity` = 1389868398 WHERE session_id = 'e9f397b37812e7e5b0563de6a32d181b';
# User@Host: root[root] @ localhost []
# Query_time: 0.022188 Lock_time: 0.000072 Rows_sent: 0 Rows_examined: 292
SET timestamp=1389868398;
UPDATE `cp_sessions` SET `last_activity` = 1389868398, `user_id` = NULL, `user_data` = 'a:3:{s:9:\"game_name\";s:5:\"poker\";s:3:\"utm\";N;s:5:\"url_1\";s:23:\"http://adda52merge.org/\";}' WHERE `session_id` = 'e9f397b37812e7e5b0563de6a32d181b';
# User@Host: root[root] @ localhost []
# Query_time: 0.000465 Lock_time: 0.000068 Rows_sent: 1 Rows_examined: 292
SET timestamp=1389868398;
SELECT *
FROM (`cp_sessions`)
WHERE `session_id` = '8c34926f9f6d711bdc14eeeb40b7db7b'
AND `ip_address` = '192.168.1.235'
AND `user_agent` = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko';
# User@Host: root[root] @ localhost []
# Query_time: 0.033085 Lock_time: 0.000036 Rows_sent: 0 Rows_examined: 292
SET timestamp=1389868398;
UPDATE `cp_sessions` SET `last_activity` = 1389868398 WHERE session_id = '8c34926f9f6d711bdc14eeeb40b7db7b';
# User@Host: root[root] @ localhost []
# Query_time: 0.000350 Lock_time: 0.000055 Rows_sent: 1 Rows_examined: 292
SET timestamp=1389868398;
SELECT *
FROM (`cp_sessions`)
WHERE `session_id` = '8c34926f9f6d711bdc14eeeb40b7db7b';
# User@Host: root[root] @ localhost []
# Query_time: 0.031274 Lock_time: 0.000043 Rows_sent: 0 Rows_examined: 292
SET timestamp=1389868398;
UPDATE `cp_sessions` SET `login_attempt` = 0 WHERE `session_id` = '8c34926f9f6d711bdc14eeeb40b7db7b';
# User@Host: root[root] @ localhost []
# Query_time: 0.000298 Lock_time: 0.000029 Rows_sent: 1 Rows_examined: 292
SET timestamp=1389868398;
SELECT *
FROM (`cp_sessions`)
WHERE `user_id` = '113';
# User@Host: root[root] @ localhost []
# Query_time: 0.000479 Lock_time: 0.000080 Rows_sent: 1 Rows_examined: 292
SET timestamp=1389868398;
SELECT *
FROM (`cp_sessions`)
WHERE `session_id` = '4809d7eef185f2bf3d8e38e1858a637c'
AND `ip_address` = '192.168.1.235'
AND `user_agent` = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko';
# User@Host: root[root] @ localhost []
# Query_time: 0.022236 Lock_time: 0.000037 Rows_sent: 0 Rows_examined: 292
SET timestamp=1389868398;
UPDATE `cp_sessions` SET `user_data` = '', `user_id` = 0 WHERE `user_id` = '113';
请帮助我,我错了,我该怎么办这个慢查询日志 我想执行那个需要更多时间执行的查询。
答案 0 :(得分:1)
设置log-queries-not-using-indexes
会将任何未使用索引的查询添加到慢速日志中。
应该激活它,因为它可以轻松帮助您优化查询。
如果您想在一定时间内查询,可以执行
SELECT * FROM mysql.slow_log WHERE query_time > 5
这将使执行时间超过5秒的查询。