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 Programming
 Index Scan

Author  Topic 

shaggy
Posting Yak Master

248 Posts

Posted - 2009-09-02 : 07:27:55
Hi all,

In a table when there is 5 records its showing Index scan in esti execution plan if it has more records its showing Index seek.

1.Table has non clustered primary key on identity column.
2.Exact NCI value is used in where clause
3.table has only 3 columns

Any body explain.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-09-02 : 08:27:05
What's your question exactly? Why is it doing a scan rather than a seek? 5 rows of data is easier to scan than to do lookups from a seek.

There's a section in Books Online on Index Seeks/Scans/Table Scans that explains what each operation does and several reasons why the operator chooses one over the other.
Go to Top of Page

eralper
Yak Posting Veteran

66 Posts

Posted - 2009-09-02 : 18:45:11
Assuming that the table has only a small number of records, this means the sql engine can read the data with one io read if they are in the same date page.

So sql will not even need for an index. Neither index scan nor index seek.

Reading from index will boost the db server performance in cases where database table has too many rows with different values for the indexed column.


-------------
Eralper
http://www.kodyaz.com
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-09-02 : 19:07:41
Why would you even bother looking at an execution plan for a tiny query that access a tiny table? Seeking or scanning a table with 5 rows is going to be super fast, so I can't imagine ever even looking at the execution plan. Are you seeing poor performance?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

shaggy
Posting Yak Master

248 Posts

Posted - 2009-09-03 : 01:00:19
Thanks all,

Iam not bother about Seek\scan for this table iam wondering how table behaves with small and large data.once again thanks
Go to Top of Page
   

- Advertisement -