I\'ve never really understood the difference between these two indexes, can someone please explain what the difference is (performance-wise, how the index structure will look li
The internal storage of indexes uses a B-Tree structure and consists of "index pages" (the root and all intermediate pages) and "index data pages" (the leaf pages only).
Note do not confuse "index data pages" with the "data pages" (leaf pages of clustered indexes) which store most of the columns of actual data.
INCLUDE
section, less data per index key is stored on each page.When an index is used, the index key is used to navigate through the index pages to the correct index data page.
INCLUDE
columns, that data is immediately available should the query need it.INCLUDE
columns, then an additional "bookmark lookup" is required to the correct row in the clustered index (or heap if no clustered index defined).Some things to note that hopefully addresses some of your confusion:
INCLUDE
columns).INCLUDE
columns as well.)It's worth noting that before INCLUDE
columns were added as a feature:
INCLUDE
columns basically allow the same benefit more efficiently.NB Something very important to point out. You generally get zero benefit out of
INCLUDE
columns in your indexes if you're in the lazy habit of always writing your queries asSELECT * ...
. By returning all columns you're basically ensuring a bookmark lookup is required in any case.