我已经在我的数据库服务器上设置了 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;