SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
David Durant
David Durant
SSC-Addicted
SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)

Group: General Forum Members
Points: 448 Visits: 23
Comments posted to this topic are about the item Stairway to SQL Server Indexes: Step 10, Index Internal Structure
Christopher Teixeira
Christopher Teixeira
SSC Rookie
SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)SSC Rookie (29 reputation)

Group: General Forum Members
Points: 29 Visits: 148
Enjoying the series. Looking forward to the rest of them. Hurry hurry lol.:-)
David Durant
David Durant
SSC-Addicted
SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)

Group: General Forum Members
Points: 448 Visits: 23
Am dancing as fast as I can.

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

Dave.
j-g
j-g
Grasshopper
Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)Grasshopper (23 reputation)

Group: General Forum Members
Points: 23 Visits: 56
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.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)

Group: General Forum Members
Points: 414246 Visits: 47128
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
patrickmcginnis59
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2691 Visits: 2333
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?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)

Group: General Forum Members
Points: 414246 Visits: 47128
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
patrickmcginnis59
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2691 Visits: 2333
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!
GilaMonster
GilaMonster
SSC Guru
SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)SSC Guru (414K reputation)

Group: General Forum Members
Points: 414246 Visits: 47128
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
Andre Guerreiro
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: General Forum Members
Points: 3355 Visits: 1515
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search