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
 General SQL Server Forums
 New to SQL Server Administration
 Index scan and Index seek

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-06-24 : 08:27:49
Hi All,
What is the difference between index scan and index seek.

Regards,
aak

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2009-06-24 : 09:51:11
An index seek is a search in an index that is in the correct order given the search criteria, and the query optimizer will know exactly where to find the data it's looking for. If the index is not ordered correctly with a given search criteria you'll get a scan. Have a look at this dummy index:
Col1      Col2
1 1
2 2
3 3
4 1
5 2
6 3
A "select * from table where col1 = 3" will give an index seek because the data is ordered and the query optimizer knows that it doesn't have to look any further in the index to find more corresponding values. A "select * from table where col2 = 3" will give a scan since the query optimizer doesn't know how many instances there are of 3 or where they are located.

- Lumbago
Go to Top of Page
   

- Advertisement -