I am using SQL Server 2008, and in one of my tables I implemented a (clustered) primary key in my identifier. Here is the table description:
Identifier: - IdentifierId int NOT NULL PK - Alias nvarchar (200) - DataType int NOT NULL
I made two indexes: one for Alias and one for DataType. However, I noticed something strange. When executing the following query:
SELECT * FROM IDENTIFIER WHERE DataType = 1
A query actually works slower with indexes and a primary key than without them; It takes about 10 seconds longer! Indexes are not fragmented - I checked - and I also use this
GO CHECKPOINT; GO DBCC DROPCLEANBUFFERS; GO DBCC FREEPROCCACHE; GO
before the request itself.
This table is quite large, with several million entries on it. Indexes and PCs play a vital role in most queries, but in this case I cannot understand why the query works slower with them. Any ideas?
Thank you in advance
EDIT: The execution plan shows that only a clustered index is used, and the DataType variable currently reaches 150.
mrlolzy
source share