Sql-server – the best index implementation for a really large databse

indexperformancesql server

I have a really large SQL SERVER table with only non clustered indices for several columns , while querying the table the execution plan shows RID Lookups , i expected to see this kind of lookup because the columns in the select list are not part of a covering index or included in another index .

The non-clustered indices were created on several columns because each one of these columns is a part of a different query with different select lists and search conditions.

Due to size and storage issues creating a covering index or a new index with included columns while keeping the current non-clustered indices is not feasible.

Now the question is :

  1. Can i replace the non-clustered indices with one covering index ?
  2. If not, is there any way to get rid of RID Lookup rather than a covering index ?
  3. Does each query require a different covering index depending on the columns in the select list and the search conditions ?
  4. I have no clustered indexes in the table , does adding a unique column and setting it as a primary key helps in getting rid of RID Lookups ?
  5. Any notes or comments to solve such problems are welcome ..

Best Answer

Can i replace the non-clustered indices with one covering index ?

No. Suppose you sometimes find people by LastName and sometimes by FirstName. An index on (LastName, FirstName) won't help you find people by FirstName.

If not, is there any way to get rid of RID Lookup rather than a covering index ?

Not in a way that's particularly useful.

Does each query require a different covering index depending on the columns in the select list and the search conditions ?

Pretty much. Your job is to come up with a compromise.

I have no clustered indexes in the table , does adding a unique column and setting it as a primary key helps in getting rid of RID Lookups ?

A PK doesn't necessarily mean a clustered index. And having a CIX just means your RID Lookups will become Key Lookups, which are potentially worse. But without CIXs you have heaps which can fragment when you change or delete data. So CIXs are fine, but won't improve performance of your Lookups.