Indexing, Index Search, and Table Crawl

I have the following table:

Create table Tab_with_Ix
(
    id int not null,
    name nvarchar(10),
    phone decimal(10,0)
)

I inserted a few entries:

insert into Tab_with_Ix 
values(1, 'Yogesh', 8855664452), (2, 'Vinay', 9977884455), (3, 'Sam', 9988554466)

Now I am creating a non-clustered index on Tab_with_Ix:

CREATE NONCLUSTERED INDEX NCI_Ix on Tab_with_Ix(id)

Now when I request Tab_with_Ix:

Select * 
from Tab_with_Ix
where id = 1

I get the execution plan as:

enter image description here

But when I use the following query:

Select id 
from Tab_with_Ix 
where id = 1

I get the execution plan as:

enter image description here

My question is: why does SQL Server use a table scan once and another time the index searches?

+4
source share
1 answer

SELECT * - , SQL Server . ( ), ( RID, ).

, - SQL Server ( ) / RID - - - ( " " ) SQL Server .

, SELECT id, id - - SQL Server , , - , , .

, SELECT * FROM dbo.Table , . SELECT *, , , ( ).

+5

All Articles