On Tue, May 20, 2008 at 11:33 AM, Perrin Harkins <[EMAIL PROTECTED]> wrote: > If that subselect only returns a single result, try using = instead of > IN. MySQL performed very poorly on OR queries before version 5. It > would avoid using indexes. The new index merge stuff in version 5 > fixed that. > > Also, this query is probably better written as a JOIN.
Agreed on the join, disagree about OR queries in general. Index merge is good queries like WHERE index_col1 ='foo' OR index_col2 = 'bar' If mysql didn't suck dealing with subqueries this fellow would have a result set transformed into something like: WHERE index_col1 ='foo' OR index_col1 = 'bar' which can definitely use an index on 3.23 (though for a multi column index index_col1 would need to be the left most column... but that is another longer explanation) http://dev.mysql.com/doc/refman/5.0/en/index-merge-optimization.html -- Rob Wultsch [EMAIL PROTECTED] wultsch (aim) -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]