Quote Originally Posted by Bok View Post
I'd bet >90% is on the filesort in either case and it may well be skewed once it's in the query cache.

12 secs is pretty decent for 5M rows anyway.
I have query caching disabled but yes 12 secs is pretty decent. For fun I took out the UNION and timed the two SELECT statements separately.

SELECT1 = 4.672 sec
SELECT2 = 3.469 sec
TOTAL = 8.141 sec

Of course you can't really do that since the second SELECT by itself returns the same number of rows as the first most of which is duplicated. But it looks like the UNION part takes 4 seconds.