FIX: Optimizer Chooses Inefficient Clustered Index on Query with Date Range Condition

Article translations Article translations
Article ID: 246474 - View products that this article applies to.
This article was previously published under Q246474
This article has been archived. It is offered "as is" and will no longer be updated.
BUG #: 56775 (SQLBUG_70)
Expand all | Collapse all

SYMPTOMS

When executing a query with a WHERE clause that references a date column that has a clustered index and any other column having a non-clustered index, SQL Server may choose an inefficient clustered index resulting in excessive response time to the user.

The optimizer chooses an inefficient clustered index. Forcing a non-clustered index gives much better performance in a simple SELECT statement with 2 search arguments (SARGs), one of which is a DATE range.

If a table has a clustered index on date column (column1) and non-clustered index on any other column (column2) and you perform a simple SELECT on the table with WHERE condition BETWEEN date range (column1) AND column2 = 'value' like this:
select *  from table1
where column1 between 'date1' and 'date2' and column2 = 'value'
				
The optimizer choses the clustered index on column1 even though use of a non-clustered index on column2 gives better performance. That is, less CPU time and logical reads.

WORKAROUND

Force the non-clustered index using a table hint.

STATUS

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.

Properties

Article ID: 246474 - Last Review: October 22, 2013 - Revision: 2.1
APPLIES TO
  • Microsoft SQL Server 7.0 Standard Edition
Keywords: 
kbnosurvey kbarchive kbbug kbfix KB246474

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com