Tom
Tom

Reputation: 61

What is the difference between composite non clustered index and covering index

SQL Server 2005 includes "covering index" feature which allows us to select more than one non key column to be included to the existing non clustered index.

For example, I have the following columns:

EmployeeID, DepartmentID, DesignationID, BranchID

Here are two scenarios:

What is the difference between the above two? If both are same what's new to introduce "Covering Index" concept?

Upvotes: 6

Views: 3281

Answers (2)

helpME1986
helpME1986

Reputation: 1013

Covered index is a nonclustered index with INCLUDE clause

Upvotes: 0

Mark Byers
Mark Byers

Reputation: 839054

The difference is that if there are two rows with the same DepartmentID in the first index they will be sorted based on their values of DesignationID and BranchID. In the second case they will not be sorted relative to each other and could appear in any order in the index.

In terms of what this means to your application:

  • A query which can use an index on (DepartmentID, DesignationID) can be more efficient with the first query than the second.
  • Building the first index may take slightly longer because of the extra sorting required.

Upvotes: 3

Related Questions