Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

A lot of programming language when you use an OR, he will check the first condition to be true and won't check the rest of the condition.

for example

true OR (false) OR (1) OR (false) OR ....... OR (0)

with the first true it's enough to keep going and there is no need to check the rest. If we apply that theory to the LIKE.

Select * from T1 where col1 like '%me' or like 'me%' 

would be a little bit faster than

Select * from T1 where col1 like '%me%'

because when he found some text with the text '%me' the condition will be true, it will show the result and keep searching to the next row.

What do you think about this?

EDIT: COL1 IS A VARCHAR(3) to have the same result (thanks Aaron Bertrand and Justin Cave for this recommendation)

share|improve this question
2  
This is too general as a database-agnostic question - it needs to be re-asked with a RDBMS specific tag to be answerable. – Jack Douglas May 18 '12 at 21:23

closed as not a real question by JNK, Thomas Stringer, Aaron Bertrand, Jack Douglas May 18 '12 at 21:23

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, see the FAQ.