I have a query which is returning the below explain:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE this_ index_merge CategoryId,Deleted,PublishedOn,_ComputedDeletedValue,_Temporary_Flag,Published,_TestItemSessionGuid Deleted,_ComputedDeletedValue,_Temporary_Flag,Published 1,1,1,1 6203 Using intersect(Deleted,_ComputedDeletedValue,_Temporary_Flag,Published); Using where
Does this show that the query is using indexes everywhere, or can it be improved by adding other indexes? Based on this: http://dev.mysql.com/doc/refman/5.1/en/explain-output.html, it mentions that the key
column shows the indexes actually used. I have an index on every column.
The query in question is the below:
SELECT SQL_NO_CACHE count(*) FROM
article this_
WHERE
(this_._Temporary_Flag = 0 OR this_._Temporary_Flag = NULL) AND
this_.Published = 1 AND
(this_.PublishedOn IS NULL OR this_.PublishedOn <= '2012-10-30 18:46:18 ') AND
(this_.Deleted = 0 OR this_.Deleted = NULL) AND
(this_._ComputedDeletedValue = 0 OR this_._ComputedDeletedValue = NULL) AND
((this_._TestItemSessionGuid IS NULL OR this_._TestItemSessionGuid = ''))
AND NOT (this_.CategoryId IS NULL)
Table has approximately 140,000 records. This query is taking 3 seconds to execute, and returning 135,725 as result.