The information in this article applies to:
SYMPTOMSIt takes a long time to execute a query that uses a WHERE clause with multiple IN or OR options. However, if the same query is broken up into shorter separate queries, and the OR or IN options are not used, the performance improves dramatically. CAUSE
Before SQL Server executes a query, it first attempts to optimize
the query. In the optimization step, it looks at what, if any,
indexes exist on a table, and decides whether those indexes will be
useful in the execution of the query. In addition, it examines the
conditions in the WHERE clause to estimate how many rows will be
affected by the query.
WORKAROUNDIn these instances, better performance can be obtained by breaking the query into separate, smaller queries. This is not to say, however, that the OR and IN options should never be used. There are situations where using an OR or IN option will give better performance than using separate queries. Additional query words: Transact-SQL dblib Windows NT
Keywords : kbprg SSrvDB_Lib SSrvTran_SQL SSrvServer SSrvWinNT |
Last Reviewed: March 10, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |