I have the following query I need help with.
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
All the fields in the query are indexed, but when I run an explain I get the following:
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)
I need to have log-queries-not-using-indexes enabled in my.cnf
Can anyone suggest how I could rewrite this query to keep it out of the slow log?