SlideServe
Menu
Préférences
© SlideServe · v2026

Mastering SQL Indexing: Clustered, Non-Clustered, and Filtered Indexes Demystified

garvey avatar
22 diapositives · 318 Views · Jul 29, 2014

Dive deep into the world of SQL indexes with expert Denny Cherry. Learn the internals of clustered, non-clustered, and filtered indexes, and understand the structures and navigation techniques within B-trees. Unlock the keys to optimizing SQL query performance. Follow along with real examples and visual explanations to enhance your SQL indexing skills.

Mastering SQL Indexing: Clustered, Non-Clustered, and Filtered Indexes Demystified - slide 1
01 / 22Mastering SQL Indexing: Clustered, Non-Clustered, and Filtered Indexes Demystified
1 / 17

Télécharger la présentation

Mastering SQL Indexing: Clustered, Non-Clustered, and Filtered Indexes Demystified
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Indexing Internals Denny Cherry mrdenny@mrdenny.com twitter.com/mrdenny

  2. About Me • Author or Coauthor of 4 books • 8+ SQL Mag articles • Dozens of other articles • Microsoft MVP since Oct 2008 • Microsoft Certified Master • Founder of SQL Excursions • Independent Consultant

  3. What we’ll be covering… • Clustered Indexes • Non-Clustered Indexes • Filtered Indexes

  4. What we won’t be covering… • Spatial Indexes • Full Text Indexes • Compressed Indexes • Columnar Store Index

  5. Structures… • Indexes are made up of B-Trees which make the index navigable • Indexes are almost always made up of at least two data pages. • A Root Page • A Leaf Page • Clustered Indexes also have Data Pages • Lets look at a pretty picture…

  6. Clustered Index

  7. Clustered Index Data Page • Contains one row for every row in the table • Contains all in row data • Contains pointers to out of row data • TEXT • NTEXT • IMAGE • Contains pointers to overflow data • XML • VARCHAR(MAX) • NVARCHAR(MAX) • VARBINARY(MAX)

  8. Slot Array • Shows what row within the page each row occupies • Contains the Clustered Index value and row id only

  9. Clustered Index Intermediate Levels • Contains one row, for each page below it • Each row contains… • Clustered Key Value • File Id (2 bytes) • Page Id (4 bytes) • Row Overhead (At least one byte) • Slot array location within this page (2 bytes)

  10. Row Overhead? • 1 Byte by default • Nulls? • Variable Width Data Types?

  11. Clustered Index Root Page • Only a single root page can exist • Contains one row, for each page below it • Each row contains… • Clustered Key Value • File Id (2 bytes) • Page Id (4 bytes) • Row Overhead (At least one byte) • Slot array location within this page (2 bytes)

  12. Navigating The Clustered Index

  13. Splitting the Root Page

  14. Uniqueifier … • Non-Unique clustered indexes have an extra column called the uniqueifier which ensures that values within the index are unique. • Uniqueifier is only used for rows which are not unique.

  15. Non-Clustered Index

  16. Nonclustered Index Intermediate Page • Contains one row for every row in the table • Contains indexed value and clustered index key or RID

  17. NonClustered Index Root Page • Only a single root page can exist • Contains one row, for each page below it • Each row contains… • Indexed Key Value • Clustered Key Value or RID (if index is not unique) • File Id (2 bytes) • Page Id (4 bytes) • Row Overhead (At least one byte) • Slot array location within this page (2 bytes)

  18. Navigating The NonClustered Index

  19. Navigating The Clustered Index

  20. B-Tree Sizes • Each B-Tree page can store info about X child pages… • INT = 8096/13 bytes = 622 pages • BIGINT = 8096/17 bytes = 476 pages • GUID = 8096/25 bytes = 323 pages

  21. Sample Index Size Sample table has a clustered key which is an Integer. • Root Level = 1 page • Intermediate Level = 7 pages • Data Pages = 11233 pages • Another page level requires 7,650,600 data pages for a fourth level

  22. Denny Cherry mrdenny@mrdenny.com http://itke.techtarget.com/sql-server Please fill out the survey at http://speakerrate.com/mrdenny.