Sql-server – non clustered index coverage with INCLUDED columns

covering-indexindex-tuningnonclustered-indexperformancequery-performancesql server

If I have two indexes:

IDX_1 = (COL1), (COL2) DESC
IDX_2 = (COL1) INCLUDE (COL3)

will a single defined below cover both queries? does the Descending keyword have any bearing on the usage of INCLUDE statement for covering both queries?

IDX_3 = (COL1) INCLUDE (COL2), (COL3) 

Best Answer

You didn't show us any queries.

Perhaps you asked whether IX3 will be a full substitute for 1 and 2? If so:

Pretty much. Except:

  1. For IX1, SQL Server can navigate the index tree to find all values for COL1 and keep navigating the tree to find all COL2.
  2. Also, IX1 can potentially assist in eliminating a sort for COL1, COL2 DESC.

Except for above cases, as far as I can see, IX3 will be a substitute for both IX1 and IX2 (pls comment other cases I missed and I'll add them to the above list).

DESC has no bearing on included columns. They are just "brought along", they don't influence any sorting for the index (and the values are only in the leaf).