Optimization Guidelines for OR operator

greenspun.com : LUSENET : SQL Server Database Administration : One Thread


We have several queries using the logical OR operator. Would you have guidelines on optimizing such types of queries? For the SQL implementation of other databases, we could only use OR for non-indexed columns. If such columns within the boolean expression using OR were indexed, we had to re-write the query using UNION.

Thanks, Chelo

-- Anonymous, January 27, 2000



I would use an OR unless the query analyzer indicates that I will get better performance from the UNION. An OR should have to do only a single pass through the table/indexes, whereas a UNION has to do two passes, and then concatenate the results.

Hope this helps,


-- Anonymous, January 27, 2000

Moderation questions? read the FAQ