I have a table with a composite primary key. It creates clustered index. If I use a few columns from that composite primary key in a WHERE clause, will that index be still effective? Or do I have to make new index based on the columns used in WHERE? Any help would be appreciated.
I have a table with a composite primary key. It creates clustered index. If
Share
Any index, whether clustered or not, is only useful to a query provided it’s Left-most columns in the definition are all part of the WHERE clause.
If you have an index on
(Col1,Col2,Col3), then this index can be useful for WHERE clauses that use all 3 columns, orCol2andCol1, or justCol1. But as soon asCol1isn’t included in the search, the index is useless.