Microsoft KB Archive/274329

From BetaArchive Wiki
Knowledge Base


FIX: Optimizer Slow to Generate Query Plan for Complex Queries that have Many Joins and Semi-Joins

Article ID: 274329

Article Last Modified on 10/9/2003



APPLIES TO

  • Microsoft SQL Server 2000 Standard Edition



This article was previously published under Q274329

BUG #: 236107 (SHILOH_bugs)

SYMPTOMS

When compiling complex queries that involve many views, which have more than 20 tables, joins, GROUP BY clauses, sub-queries and outer-joins, the optimizer takes a long time to produce a query plan. SQL Server still processes other queries and CPU use is high during this time.

CAUSE

The SQL Server query optimizer is a cost based optimizer and the optimizer is trying to build an optimal query plan. During optimization, the large number of joins, views, GROUP BY clauses, sub-queries and outer-joins are broken down into simpler operations, including semi-joins. Semi-joins interact with the join reordering logic and cause an increase in the combinations considered in higher levels of the operator tree. The server considers a large number of join permutations that are changed by the semi-joins below it, which results in reordering at the higher levels. In effect, the time to generate the optimal plan is much higher and it may appear that the query has stopped responding (hang).


RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft 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


Hotfix

NOTE: The following hotfix was created prior to Microsoft SQL Server 2000 Service Pack 1.

The English version of this fix should have the following file attributes or later:

   File name       Platform
   --------------------------

   s80204I.exe     Intel X86
                

NOTE: Due to file dependencies, the most recent hotfix or feature that contains the preceding files may also contain additional files.

STATUS

Microsoft has confirmed that this is a problem in Microsoft SQL Server 2000. This problem was first corrected in SQL Server 2000 Service Pack 1.


Additional query words: query hung opt lost loop infinite unresponsive sluggish perf performance

Keywords: kbbug kbfix kbqfe kbsqlserv2000sp1fix KB274329