MySQL Forums
Forum List  »  Performance

Re: Slow query
Posted by: Rick James
Date: December 11, 2015 06:56PM

A SELECT (such as in the EXISTS) can be fast if it can use an INDEX.

"WHERE ... OR ..." cannot use any index and must scan the whole table (or at least until if finds a hit (in the case of EXISTS)).

EXISTS ( SELECT * FROM t WHERE ... )
OR
EXISTS ( SELECT * FROM t WHERE ... )

might run faster.

Options: ReplyQuote


Subject
Views
Written By
Posted
1776
December 11, 2015 01:00PM
806
December 11, 2015 05:00PM
Re: Slow query
803
December 11, 2015 06:56PM
704
December 12, 2015 07:34AM
813
December 14, 2015 02:34AM
669
December 15, 2015 08:48AM
736
December 15, 2015 10:57AM
837
December 16, 2015 02:33AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.