标签归档:慢查询

MySQL类型不匹配导致的慢查询

这是个慢查询

SELECT *, `user_id` as uid
FROM (`journals`)
WHERE `user_id` IN ('1456870', 2573141) -- 字符串
AND `status` =  1
ORDER BY `id` desc
LIMIT 20

这个则不是

SELECT *, `user_id` as uid
FROM (`journals`)
WHERE `user_id` IN (1456870, 2573141) -- 数字
AND `status` =  1
ORDER BY `id` desc
LIMIT 20