Microsoft KB Archive/299950

= FIX: Bad Cardinality Estimate Results in Sub Optimal Join Strategy =

Article ID: 299950

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft SQL Server 7.0 Standard Edition

-



This article was previously published under Q299950



BUG #: 101678 (SQLBUG_70)



SYMPTOMS
A slower than optimum join strategy is chosen for the join of two tables.

The STATISTICS PROFILE output for the problem query indicates that the estimated number of rows (as indicated by the EstimateRows column) to be output by a given join operation is significantly lower than the actual number of rows output by the join (as indicated by the Rows column).



CAUSE
In some instances, the maximum value for a given column is not represented in the histogram steps of the statistical information stored for a given column.

In certain cases (like an equi-join of two columns), the ranges of values stored in the statistical histogram are compared in an attempt to estimate the number of rows that are to be output by a given join operation. In the special case where the maximum value is also a frequent value in the table being joined to, the optimizer under costs the join.



RESOLUTION
To resolve this problem, obtain the latest service pack for Microsoft SQL Server 7.0. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

301511 INF: How to Obtain the Latest SQL Server 7.0 Service Pack

NOTE: The following hotfix was created prior to Microsoft SQL Server 7.0 Service Pack 4.

The English version of this fix should have the following file attributes or later:   File name     Platform --

s70996i.exe  Intel s70996a.exe  Alpha NOTE: Because of file dependencies, the most recent hotfix or feature that contains the preceding files may also contain additional files.



WORKAROUND
Use a join hint to force a more efficient join strategy.

Please exercise caution when you force a join strategy for two tables through a join hint. If a join hint is specified for any two tables, the query optimizer automatically enforces the join order for all joined tables in the query, based on the position of the ON keywords.



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 Microsoft SQL Server 7.0 Service Pack 4.



MORE INFORMATION
After you apply this fix, you must update the statistics for the table that was affected by this problem. This step is necessary to realize the benefit of this fix.

For more information regarding how to update the statistics for a given table, refer to the &quot;UPDATE STATISTICS (T-SQL)&quot; topic in SQL Server 7.0 Books Online.

Note that if AUTO UPDATE STATISTICS is enabled for the database, the problem should be corrected automatically the next time the statistics are updated for the problem table.

Additional query words: slow statistics performance

Keywords: kbbug kbfix KB299950

-

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

© Microsoft Corporation. All rights reserved.