Hello,
i'm using SQL Server 2008 and, in one of my tables, i implemented a (clustered) primary key on its identifier. Here's the table description:
Identifier: - IdentifierId int NOT NULL PK - Alias nvarchar(200) - DataType int NOT NULL
I made two indexes: one for Alias and another one for DataType. However, I just noticed something strange. When running the following query:
SELECT * FROM IDENTIFIER WHERE DataType = 1
The query actually runs slower with the indexes and the primary key than without them; it takes approximately 10 seconds longer! The indexes are not fragmented - i checked - and i'm also using this
GO
CHECKPOINT;
GO
DBCC DROPCLEANBUFFERS;
GO
DBCC FREEPROCCACHE;
GO
before the query itself.
This table is rather large, having several million entries on it. Indexes and PKs play a vital role on most queries, but in this case i can't understand why the query is running slower with them. Any ideas?
Thanks in advance
EDIT: The execution plan shows that only the clustered index is being used and the DataType variable currently goes up to 150.