Microsoft KB Archive/292316

= FIX: Bad Plan May Be Chosen for Subquery with Aggregate and OR Clause =

Article ID: 292316

Article Last Modified on 6/4/2003

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q292316



BUG #: 352147 (SHILOH)



SYMPTOMS
If a subquery contains multiple predicates with an OR condition, and the query also contains an aggregate (such as MAX or MIN), which the optimizer decides to calculate through a GROUP BY operation, the optimizer may fail to pick an optimal plan. Typically, the bad plan may involve a scan of the table referenced in the subquery.



CAUSE
The optimizer flattens the subquery into a join and may move some of the filter conditions independently of the GROUP BY clause, which results in a query tree that is not able to use an index efficiently.



RESOLUTION
To resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 INF: How to Obtain the Latest SQL Server 2000 Service Pack



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in SQL Server 2000 Service Pack 1.

Keywords: kbbug kbfix kbsqlserv2000sp1fix kbsqlserv2000bug KB292316

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.