Confused about the index on the Sql server

I have the following table structure:

enter image description here

When I set the column Idas the primary key, it automatically creates an index with a name PK_TestIndexTbl (Clustered)in the Indexes folder. My table contains about 1,300,000 records, and when I execute the following query, it takes about 5 seconds:

SELECT [Id], [Name], [Family], [Score]
FROM   [TestIndexTbl]

But when I delete the primary key from the table and, of course, delete the index, I expect my query to take more than 5 seconds, because now I do not have an index. But it does not matter, and I get the result after 5 seconds, as before. Why?

: ? , ? Where . :

SELECT [Id], [Name], [Family], [Score]
FROM   [TestIndexTbl]
where Id = 602145
+4
4

, . , , , .

+4

, . SQL Server B+. , , , B +.

,

  • Non Clustered

, .

, Heap. , .

, , , .

, (SELECT * FROM...), , , , . SQL- , . .

:

SELECT [Id], [Name], [Family], [Score]
FROM   [TestIndexTbl]
WHERE Id = 602145

, , , . , . , .

+1

WHERE, , . , , .

, heap.

WHERE ID = @Id, .

+1

, . , , .

. .

0

Source: https://habr.com/ru/post/1671677/


All Articles