FIX: Regression: Compilation of Many UNIONs Takes Excessively Long Time (274706)



The information in this article applies to:

  • Microsoft SQL Server 7.0 Service Pack 1
  • Microsoft SQL Server 7.0 Service Pack 2

This article was previously published under Q274706
BUG #: 57921 (SQLBUG_70)

SYMPTOMS

Beginning with SQL Server 7.0 Service Pack 1 (build 699 and higher), the compilation of a SQL statement containing many UNIONs takes substantially longer than on the golden version (build 623).

CAUSE

WORKAROUND

Reduce the number of UNIONs. If possible, avoid having more than about 40 UNIONs in a single SQL statement.

STATUS

Microsoft has confirmed this to be a problem in SQL Server 7.0. This problem has been corrected in U.S. Service Pack 3 for Microsoft SQL Server 7.0. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

274799 INF: How to Obtain Service Pack 3 for Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0

For more information, contact your primary support provider.

MORE INFORMATION

In every version of SQL Server of course, the compilation time is proportional to the number of UNIONs in a query. However, in SQL Server 7.0 Service Pack 1 and Service Pack 2, the impact of a large number of UNIONs is dramatic. The chart below compares the time for parse and compile time (CPU) between build 623 and 699. Each subset of the UNION queries was "select * from authors".

No. of Unions204080160320
Build 623 (ms)6320362521567938
Build 699 (ms)7936019061257896156

Modification Type:MajorLast Reviewed:3/14/2006
Keywords:kbBug kbfix KB274706