我想要做的是加快这个查询。目前它慢了大约 15 秒以上。r.email和v.sent以及r.id、r.viewed和r.saved 都有索引。EXPLAIN 显示两个键都在使用中,但是我看到它正在使用Using where; Using temporary; Using filesort
.
有关改进此查询的任何想法?
SELECT r.id, r.top, r.email
FROM request as r
WHERE r.viewed = 0 AND r.saved = 0 AND r.email NOT IN (
SELECT v.sent FROM viewing as v WHERE v.sent = r.email
)
GROUP BY r.email
ORDER BY r.top desc, r.date
LIMIT 100;