簡體   English   中英

Mysql慢查詢日志記錄更快的查詢

[英]Mysql slow query log is logging faster queries

我在我的數據庫服務器上設置了mysql慢查詢日志,並將長查詢時間設置為5.只需檢查日志及其日志查詢,只需幾毫秒。 任何人都知道為什么會這樣?,這里有一些日志。

最后一個查詢並不是最優化的。 它說它檢查了450000行,所以我不會驚訝地看到它在日志中。 然而查詢時間表示只花了0.2秒。 慢查詢日志還有更多信息,只需查詢執行時間嗎?

# Query_time: 0.000525  Lock_time: 0.000151 Rows_sent: 1  Rows_examined: 115
SET timestamp=1349393722;
SELECT `we_members`.*, `we_referrals`.`code` as referral_code
FROM (`we_members`)
LEFT JOIN `we_referrals` ON `we_referrals`.`m_id` = `we_members`.`id`
WHERE `we_members`.`facebook_id` = '100'
LIMIT 1;

# Query_time: 0.000748  Lock_time: 0.000104 Rows_sent: 3  Rows_examined: 691
SET timestamp=1349393722;
select distinct(m_id), m.first_name, m.facebook_id, m.photo_url from
            we_connections f
            left join we_members m on m.id = f.m_id
            where ( (f.friend_id = 75 or f.m_id = 75 and m.id != 75))
            and m.id >0
            and m.id != 75
            order by m_id;

# Query_time: 0.259535  Lock_time: 0.000098 Rows_sent: 16  Rows_examined: 455919
SET timestamp=1349393722;
select distinct(m_id), m.first_name, m.facebook_id, m.photo_url from
            we_connections f
            left join we_members m on m.id = f.m_id
            where (f.friend_id IN (select friend_id from we_connections f where f.m_id = 75) or (f.friend_id = 75 or f.m_id = 75 and m.id != 75))
            and m.id >0
            and m.id != 75
            order by m_id;

鑒於在某些查詢中檢查了大量行,您可能也設置了log_queries_not_using_indexes選項 - 任何不使用索引的查詢也將寫入慢查詢日志。 您可以在my.cnf文件中檢查此選項。

http://dev.mysql.com/doc/refman/5.5/en/server-options.html#option_mysqld_log-queries-not-using-indexes

有關寫入日志的查詢類型的更多信息,請訪問http://dev.mysql.com/doc/refman/5.5/en/slow-query-log.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM