question

matta1985 avatar image
matta1985 asked

Sql server indexes

In a SQL Server Execution plan what is the difference between an Index Scan and an Index Seek
indexingperformance-tuning
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
This site works on the concept of votes. For each of the answers below that was helpful you should indicate this by clicking on the thumbs up next to those answers. If anyone of the answers below helped solve your problem you can indicate that by clicking on the check mark next to that answer.
0 Likes 0 ·
Grant Fritchey avatar image
Grant Fritchey answered
If you look at the properties for the operator it will explain what each one does. A scan looks at all or a significant part of a table or index. A seek looks at a more limited range of the index. The scan generally walks the pages where as a seek generally uses the key structure to find information. That's it in a nutshell.
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·
And you missed the chance to pimp your [SQL Server Execution Plan][1] book... ;-) [1]: http://www.red-gate.com/community/books/sql-server-execution-plans-ed-2
3 Likes 3 ·
Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
ha! Or, I didn't feel like looking up the URL. Thanks for posting it.
1 Like 1 ·
JohnM avatar image
JohnM answered
In a nut shell, an index scan will look (scan) the whole table/index and the the index seek will only look at pages that contain the rows that meet the criteria of the query (IE: where clause). Pinal Dave has a good explanation for this: http://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/ Hope this helps!
2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Grant Fritchey avatar image Grant Fritchey ♦♦ commented ·
Although, a scan can look at a subset of the data and a seek could end up seeking against the entire table/index. SQL Server is fun!
4 Likes 4 ·
JohnM avatar image JohnM commented ·
Very true! An excellent point!
0 Likes 0 ·
skpani avatar image
skpani answered
Index seek: Because your query is selective enough, you can go directly to the items you need through the index. Example: SELECT * FROM Employee WHERE EmpID = 12345 Index scan: Because your query isn't quite selective enough, so the whole index is being run through to find out which rows are required.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.