Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 query not using index

Author  Topic 

creane
Starting Member

11 Posts

Posted - 2003-09-02 : 07:25:43
Hi, Ive a problem whereby my sql query (sql server 2000) is doing a clustered index scan on a table which is causing problems in an application.
The query is
SELECT emailaddress, datejoined, nationality, status
FROM table
WHERE status < max_status_variable and nopromos = '0'
order by emailaddress

emailaddress is a clustered index, status is in a covering index with datejoined (non clustered index obviously status,datejoined being the order of the index).. Using the query execution plan in sql analyser is shows that the status < max_status_variable is not using the covering index at all (there are a million records in teh database table)...if I run the query on development it works fine, anybody any ideas on how to run the query effeciently or is it a matter of drop and creating different indexes

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2003-09-02 : 08:43:20
have a look at index hints....this may improve your problem....but they are not perfect in all situations

SELECT emailaddress, datejoined, nationality, status
FROM table with index (3))
WHERE status < max_status_variable and nopromos = '0'
order by emailaddress
Go to Top of Page
   

- Advertisement -