我有以下需要帮助的查询。
SELECT a.artist, a.facepic
FROM artists_vs AS v, artists AS a
WHERE v.genreid =0
AND (v.artistid1 = a.artistid OR v.artistid2 = a.artistid)
ORDER BY v.bid DESC
LIMIT 20
查询中的所有字段都已编入索引,但是当我运行解释时,我得到以下信息:
1 SIMPLE v ref genreid,artistid1,artistid2 genreid 4 const 15 Using temporary; Using filesort
1 SIMPLE a ALL PRIMARY NULL NULL NULL 18165 Range checked for each record (index map: 0x1)
我需要在 my.cnf 中启用 log-queries-not-using-indexes
谁能建议我如何重写此查询以使其远离慢速日志?