This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 364245 (SQL Server 8.0)
The SQL Server optimizer may not correctly estimate the cardinality of an expression if all the following conditions are true:
The query specifies two different range conditions, such as column BETWEEN x and y or column > x.
Both of the range predicates are qualified with an AND condition.
A histogram is available for each of the two columns, either from manual or auto create statistics or from an index that specifies the column as its leading column.
Multicolumn density is available for the combination of the two columns.
The following query is an example of a query that may be affected by this problem:
SELECT *FROM a WHERE a.[SALESORG] BETWEEN 'B001' AND 'B099' AND a.[SOLD_TO] BETWEEN 'B000000001' AND 'B000010000'
In this example, histograms must exist for both SALESORG and SOLD_TO, and statistics must exist for the combination of SALESORG and SOLD_TO.
Because of this bug, the SQL Server optimizer typically underestimates the number of rows from such a predicate. The SQL Server optimizer may select a plan that is not efficient, such as using an index seek when an index scan is more appropriate, using an incorrect join order, or failing to use a matching indexed view.
Service pack information
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 How to obtain the latest SQL Server 2000 service pack
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 tool in Control Panel.
Date Time Version Size File name--------------------------------------------------------------27-Mar-2003 02:47 184.108.40.206 11,172,351 Sql2000-kb810185-8.00.0794-enu.exe
Note Because of file dependencies, the most recent hotfix or feature that contains these files may also contain additional files.
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.This problem was first corrected in Microsoft SQL Server 2000 Service Pack 4.
This fix is only enabled when you use trace flag 9256. For more information about using trace flags, see SQL Server 2000 Books Online.
Microsoft SQL Server 2000 Developer Edition, Microsoft SQL Server 2000 Standard Edition, Microsoft SQL Server 2000 Enterprise Edition, Microsoft SQL Server 2000 Personal Edition, Microsoft SQL Server 2000, Workgroup Edition, Microsoft SQL Server 2000 Desktop Engine (Windows), Microsoft SQL Server 2000 Enterprise Edition 64-bit