FIX: Bad Plan May Be Chosen for Subquery with Aggregate and OR Clause (292316)



The information in this article applies to:

  • Microsoft SQL Server 2000 (all editions)

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.

Modification Type:MajorLast Reviewed:6/4/2003
Keywords:kbSQLServ2000sp1fix kbBug kbfix kbSQLServ2000bug KB292316 kbAudDeveloper