Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/254910

From BetaArchive Wiki
Knowledge Base

FIX: Slow Performance with NOT NULL Comparison and Empty Table

Article ID: 254910

Article Last Modified on 3/14/2006


  • Microsoft SQL Server 7.0 Standard Edition

This article was previously published under Q254910

BUG #: 56596 (SQLBUG_70)


A query that contains an aggregate function, a GROUP BY clause, and an IS NOT NULL comparison on one table and a join with an empty table may run slowly. The optimizer picks a plan that uses the table with the IS NOT NULL comparison as the outer table in the join rather than the empty table. The following is the type of query that would exhibit this problem:

SELECT count(TableRows.col1), TableEmpty.col1
FROM TableRows TR, TableEmpty TE
TR.col1 = TE.col1 AND 
Group By TE.col1

For the preceding query, performance is slow under the following circumstances:

  • TableRows contains sufficient data where col2 is NOT NULL such that iterating through each qualifying row has a noticeable affect on performance.
  • TableEmpty contains no data.


If the table "TableEmpty" has at least one data row, the optimizer picks the correct plan.


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

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

For more information, contact your primary support provider.

Keywords: kbbug kbfix KB254910