Stairway to SQL Server Indexes: Step 10, Index Internal Structure

  • David Durant

    Ten Centuries

    Points: 1370

    Comments posted to this topic are about the item Stairway to SQL Server Indexes: Step 10, Index Internal Structure

  • Christopher Teixeira

    Valued Member

    Points: 65

    Enjoying the series. Looking forward to the rest of them. Hurry hurry lol.:-)

  • David Durant

    Ten Centuries

    Points: 1370

    Am dancing as fast as I can.

    Hope to have it all into Kalen (the editor) shortly.

    Dave.

  • j-g

    Valued Member

    Points: 63

    Thank you very much! Finally finished going through all 10 steps little by little and been worth every second! Looking forward to the rest of the them.

  • Gail Shaw

    SSC Guru

    Points: 1004484

    Just one correction:

    Non-leaf level entries contain only index key columns and the pointer to a lower level page. Included columns only exist in the leaf level entries; they are not carried in the non-leaf level entries.

    Non-leaf entries of a nonclustered index contain the index key columns, a pointer to the page below and, if the index has not been declared as unique, it will also contain the clustered index key or RID (depending whether the base table is a heap or clustered index). This ensures that there are never complete duplicate rows in the upper level of a nonclustered index

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • patrickmcginnis59

    SSCertifiable

    Points: 6483

    GilaMonster (1/20/2012)


    Just one correction:

    Non-leaf level entries contain only index key columns and the pointer to a lower level page. Included columns only exist in the leaf level entries; they are not carried in the non-leaf level entries.

    Non-leaf entries of a nonclustered index contain the index key columns, a pointer to the page below and, if the index has not been declared as unique, it will also contain the clustered index key or RID (depending whether the base table is a heap or clustered index). This ensures that there are never complete duplicate rows in the upper level of a nonclustered index

    Interesting! Whats the downside of having duplicate rows in nonleaf nodes? Aren't they still going to point to the correct child nodes that they're the parent of?

  • Gail Shaw

    SSC Guru

    Points: 1004484

    patrickmcginnis59 (1/20/2012)


    Whats the downside of having duplicate rows in nonleaf nodes? Aren't they still going to point to the correct child nodes that they're the parent of?

    Yes, they will, however it can be more work when modifying or deleting the rows. Imagine an index on gender and a row is deleted. That row needs to be located in the nonclustered index to be removed (from the leaf). If all we had at the intermediate levels was the gender, SQL would have to scan half the index to find the row that it needs to remove. If the index rows are unique (from the clustered key or RID), SQL can just navigate straight to the row it need to remove.

    http://technet.microsoft.com/en-us/sqlserver/gg508878.aspx (about 24 minutes in)

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • patrickmcginnis59

    SSCertifiable

    Points: 6483

    GilaMonster (1/20/2012)


    patrickmcginnis59 (1/20/2012)


    Whats the downside of having duplicate rows in nonleaf nodes? Aren't they still going to point to the correct child nodes that they're the parent of?

    Yes, they will, however it can be more work when modifying or deleting the rows. Imagine an index on gender and a row is deleted. That row needs to be located in the nonclustered index to be removed (from the leaf). If all we had at the intermediate levels was the gender, SQL would have to scan half the index to find the row that it needs to remove. If the index rows are unique (from the clustered key or RID), SQL can just navigate straight to the row it need to remove.

    http://technet.microsoft.com/en-us/sqlserver/gg508878.aspx (about 24 minutes in)

    Thanks! I didn't even consider deletes. I'll have to buy some popcorn and watch the movie!

  • Gail Shaw

    SSC Guru

    Points: 1004484

    patrickmcginnis59 (1/20/2012)


    Thanks! I didn't even consider deletes. I'll have to buy some popcorn and watch the movie!

    Not a movie. One of the MCM videos. That particular one is about 40 minutes long and all about index internals

    p.s. not just deletes, any modification that has to change the data in the index leaf

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Andre Guerreiro

    SSCertifiable

    Points: 7319

    There's just so much information in the this article and discussion!

    Please keep up the good work.

    Many books don't expose the level of detail presented here and leave us wondering how that really works from the inside.

    Thank you very much David (and Gail for the additional info and link).

    Best regards,

    Andre Guerreiro Neto

    Database Analyst
    http://www.softplan.com.br
    MCITPx1/MCTSx2/MCSE/MCSA

  • robinrai3

    SSCrazy

    Points: 2810

    David,

    This series is absolutely top draw and this internal index stuff is great. As they say a picture is worth a thousand words, these diagrams and walkthrough you give explains it all in simple and laymans terms.

    rgds

    robin

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply