Monday 30 July 2018

index scan vs index seek vs table scan

 TableScan-
When there is no index in a table then if we search like below then it is Table Scan

Create table  TestTable(id int ,Name varchar(100) , Salary int)


insert into TestTable values(2,'B',2000)
insert into TestTable values(1,'A',1000)
insert into TestTable values(3,'C',3000)

select * from TestTable where id=2
Or

select * from TestTable 


 Index Scan-
If there is any index whether it is clustered or non clustered index if we search like below then its called Index Scan-
Create table  TestTable(id int primary key ,Name varchar(100) , Salary int)


insert into TestTable values(2,'B',2000)
insert into TestTable values(1,'A',1000)
insert into TestTable values(3,'C',3000)

select * from TestTable  

index seek-
 If we search with some condition having index then its called index seek

select * from TestTable where id=2

1 comment:

  1. Greetings! Very useful advice within this post! It's the little changes which will make the biggest changes. Many thanks for sharing!

    ReplyDelete

Recent Post

Parallel Task in .Net 4.0