Microsoft KB Archive/922063

= FIX: You may notice a large increase in compile time when you enable trace flags 2389 and 2390 in SQL Server 2005 Service Pack 1 =

Article ID: 922063

Article Last Modified on 7/24/2007

-

APPLIES TO


 * Microsoft SQL Server 2005 Service Pack 1

-



Bug #: 984 (SQL Hotfix)

Bug #: 441938 (SQLBUDT)



Notice
Microsoft distributes Microsoft SQL Server 2005 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 fix release.



This article describes the following about this hotfix release:
 * The issues that are fixed by this hotfix package
 * The prerequisites for installing the hotfix package
 * Information about whether you must restart the computer after you install the hotfix package
 * Information about whether the hotfix package is replaced by any other hotfix package
 * Information about whether you must make any registry changes
 * The files that are contained in the hotfix package



SYMPTOMS
Consider the following scenario. You are running SQL Server 2005 Service Pack 1 (SP1). You enable trace flags 2389 and 2390 to enable automatically generated quick statistics for ascending keys. In this scenario, you may experience the following behavior:
 * You notice a large increase in compile time.
 * SQL Server does not generate an efficient query plan because the correct maximum value for the column cannot be determined.



CAUSE
This problem occurs because SQL Server performs a scan of the appropriate column. This scan takes extra compile time.



RESOLUTION
A supported hotfix is now available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next service pack that contains this hotfix.

To resolve this problem, submit a request to Microsoft Online Customer Services to obtain the hotfix. To submit an online request to obtain the hotfix, visit the following Microsoft Web site:

http://go.microsoft.com/?linkid=6294451

Note If additional issues occur or any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. To create a separate service request, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Prerequisites
You must have SQL Server 2005 Service Pack 1 (SP1) installed to apply this hotfix.

For more information about how to obtain SQL Server 2005 SP1, click the following article number to view the article in the Microsoft Knowledge Base:

913089 How to obtain the latest service pack for SQL Server 2005

Restart information
You do not have to restart the computer after you apply this hotfix.

Registry information
You do not have to change the registry.

Hotfix file information
This hotfix contains only those files that are required to correct the issues that this article lists. This hotfix may not contain of all the files that you must have to fully update a product to the latest build.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

SQL Server 2005 Itanium architecture version


STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
Ascending key columns can cause inaccurate statistics in tables that have frequent insert operations. These key columns may be IDENTITY columns or datetime columns that represent real-world time stamps. A common problem for some SQL Server applications are cases in which data typically ascends. For example, you have a table that contains a datetime column, and the column represents a current date. SQL Server builds statistics that assume that data will be mostly similar in the future. However, when data typically ascends, most new insertions are out of the previously found range. This behavior may cause poorly performing plans to be created. Filters that select recent data may exclude the whole relation even though a significant number of rows are included.

Trace flags 2389 and 2390 are both new in SQL Server 2005 SP1. These trace flags can help address this problem. SQL Server 2005 SP1 tracks the nature of columns by subsequent statistics updates. When SQL Server determines that the statistics increase three times, the column is branded ascending. The statistics will be updated automatically at query compile time if the following conditions are true:
 * Trace flag 2389 is set.
 * A column is branded ascending.
 * A covering index exists with the ascending column as the leading key.

A statement is compiled to find the highest value, and a new step is added at the end of the existing histogram to model the recently added data.

Trace flag 2390 enables the same behavior as trace flag 2389, even if the ascending nature of the column is not known. As long as the column is a leading column in an index, the optimizer updates the statistics that have the highest value at query compile time. Never use trace flag 2390 alone because this logic would be disabled as soon as the ascending nature of the column is known.

To enable automatically generated quick statistics for known ascending keys, run the following statement: DBCC TRACEON ( 2389, -1 ) To enable automatically generated quick statistics for all columns that include known ascending keys or unknown ascending keys, run the following statement: DBCC TRACEON ( 2389, 2390, -1 ) You can also use the -T command-line switch for Sqlservr.exe to enable these two trace flags server-wide. For more information, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/ms190737.aspx

For more information about the naming schema for Microsoft SQL Server updates, click the following article number to view the article in the Microsoft Knowledge Base:

822499 New naming schema for Microsoft SQL Server software update packages

For more information about software update terminology, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Keywords: kbexpertiseadvanced kbtshoot kbfix kbsql2005engine kbhotfixserver kbqfe kbpubtypekc KB922063

-

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

© Microsoft Corporation. All rights reserved.