2. Introduction
• Sourabh Agarwal
• Premier Field Engineer – Microsoft Services
• Blogs: www.sqluninterrupted.com
• Facebook: www.facebook.comtroubleshootingsql,
www.facebook.comsqlserverfaq
• Twitter: @napsterreturns
3. Base Table
• Heap Or Clustered Index
• If Heap, Managed by the IAM
• If Clustered managed as a Balanced Tree.
4. HEAP
• Random (Non Sequential)
collection of Pages
• Managed through the IAM (Index
Allocation Map)
5. Clustered Indexes
• Balanced Tree Structure
• Index Pages on Root and
Intermediate Pages
• Actual Data Pages as leaf Pages
• ** IAM page is still maintained
7. Non-Clustered Indexes
• Created On Top of the base Tables
• Separate Structures, occupies space in the SQL Data File
• Can be
• Unique Non Clustered Indexes
• Non-Unique Non Clustered Indexes
• Single Columns/Multi Columns
• INCLUDE can be used to store other column values in the index.
8. Non-Clustered Index on
Non-leaf
HEAP
Level
Non-clustered
Index Pages
• Index Keys on Root or
Intermediate Pages
.
. .
. .
. .
.
Leaf
. . . . • Index Keys + Row ID in
Level
. . . . the Leaf Pages
.
. .
. .
. .
. .
. .
. Data
.
. .
. .
. .
. .
. .
.
Pages
9. Non-Clustered Index On Clustered
Index Table
• Index Key Values on the Root and
Intermediate levels.
• Non-Clustered Index Key + Clustered
Index Key Value
10. DEMO
• Non-Clustered Indexes on Heap
• Non-Clustered Indexes on Clustered Index Tables
• Non-Clustered Indexes with include Columns.