HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinorCanonical

What is a non-clustered index scan

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
clusteredscanwhatnonindex

Problem

I know what table scan, clustered index scan and index seek is but my google skills let me down to find a precise explanation into non clustered index scans. Why and when a query uses a non clustered index scan?

Thank you.

Solution

A non-clustered index scan may be chosen in this scenario:

  • the optimizer determines that it is cheaper to scan all rows rather than perform seeks/range scans



  • the non-clustered index is "skinnier" than the clustered index



  • the non-clustered still covers the columns needed by the query (or it covers enough of them and a lookup for the remainder is still cheaper than a clustered index scan)



It can also happen, obviously, if you have a heap (no clustered index) and 3. is still true.

This is not meant to be an exhaustive list - there are other cases where a non-clustered index scan may be chosen, but this is probably the most common.

Context

StackExchange Database Administrators Q#80841, answer score: 8

Revisions (0)

No revisions yet.