我的代码中遇到了一个错误,其中mysql查询没有返回结果。所以,我已经设置了mysql慢速日志来获取所有查询。当一切都很好,我得到:
# User@Host: SAMP_1[SAMP_1] @ localhost []
# Query_time: 0.000061 Lock_time: 0.000000 Rows_sent: 0 Rows_examined: 0
SET timestamp=1392563921;
SELECT * FROM (SELECT 0 AS mark, ua.id AS id, ua.uid AS uid, ua.offset AS colThird, ua.value AS colFourth, NULL AS colFifth FROM `user_achievements` ua UNION ALL SELECT 1, uiw.* FROM `user_inv_weapons` uiw UNION ALL SELECT 2, ul.*, NULL FROM `user_licenses` ul UNION ALL SELECT 3, un.*, NULL FROM `user_notes` un UNION ALL SELECT 4, ups.*, NULL FROM `user_punishments` ups UNION ALL SELECT 5, us.*, NULL FROM `user_skills` us UNION ALL SELECT 6, uw.* FROM `user_weapons` uw UNION ALL SELECT 7, upk.*, NULL FROM `user_perks` upk ) AS uqq WHERE uqq.uid = 1 ORDER BY mark ASC, id ASC;
# User@Host: SAMP_1[SAMP_1] @ localhost []
# Query_time: 0.000502 Lock_time: 0.000128 Rows_sent: 2 Rows_examined: 11
SET timestamp=1392563922;
SELECT * FROM vehicles WHERE owner = 'Foo_Bar' ORDER BY id ASC LIMIT 0, 2;
看看第二行_sent - 它是2,这是正确的结果数。但是,有时,完全相同的查询不返回任何内容,而在查询之前需要更长的时间:
# Time: 140216 15:35:36
# User@Host: SAMP_1[SAMP_1] @ localhost []
# Query_time: 2.778103 Lock_time: 0.000504 Rows_sent: 84 Rows_examined: 507332
SET timestamp=1392561336;
SELECT * FROM (SELECT 0 AS mark, ua.id AS id, ua.uid AS uid, ua.offset AS colThird, ua.value AS colFourth, NULL AS colFifth FROM `user_achievements` ua UNION ALL SELECT 1, uiw.* FROM `user_inv_weapons` uiw UNION ALL SELECT 2, ul.*, NULL FROM `user_licenses` ul UNION ALL SELECT 3, un.*, NULL FROM `user_notes` un UNION ALL SELECT 4, ups.*, NULL FROM `user_punishments` ups UNION ALL SELECT 5, us.*, NULL FROM `user_skills` us UNION ALL SELECT 6, uw.* FROM `user_weapons` uw UNION ALL SELECT 7, upk.*, NULL FROM `user_perks` upk ) AS uqq WHERE uqq.uid = 1 ORDER BY mark ASC, id ASC;
# User@Host: SAMP_1[SAMP_1] @ localhost []
# Query_time: 0.000504 Lock_time: 0.000139 Rows_sent: 0 Rows_examined: 11
SET timestamp=1392561336;
SELECT * FROM vehicles WHERE owner = 'Foo_Bar' ORDER BY id ASC LIMIT 0, 2;
发生了什么事?我可以进一步检查以获得缺乏结果和/或长查询执行时间的原因?谢谢。