Search code examples
sql-serverindexingb-treephysical-design

Structure of a Multi-column index in SQL server


Where can I find a good representation of the of how data is stored in pages and how the B tree is constructed for a multi-column index (specifically for SQL server, but not necessarily)?

I'm referring to something like what you see in https://learn.microsoft.com/en-us/sql/relational-databases/reading-pages?view=sql-server-ver15 (for single column) but extended for multi-columns.

Another example for single column index: enter image description here

Thanks.


Solution

  • I found this example very informative, hope you are looking for something like this. It shows include columns as well (SQL-Server specific). If you don't need include-columns, simply take everything without 'age' and 'sex' in the leaf node. There is a good explanation in the original article (which I hope you might not need).

    enter image description here

    Reference - https://www.malinga.me/index-physical-structure-example-multi-column-non-clustered-index-with-includes/