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


Page Splits on Non-clustered unique primary Key


Page Splits on Non-clustered unique primary Key

Author
Message
Latheesh NK
Latheesh NK
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5161 Visits: 2164
I have a situation like below and would like to get your expert opinion on the same.

We have a table TableA. It has a identity column Col_Ident but has clustered index defined on some other column Col_CLI because of access pattern. Now, we understand that page splits will occur in the clustered index on Col_CLI. But we are not sure whether Col_Ident(non-clustered, primary key) will ever undergo a page split.

I’m of the opinion, that there will be no page splits in the non-clustered index on Col_Ident since it is a monotonically increasing column. But, one of my friend says that since the non-clustered index will be based on the clustering key, there could be page splits.

I was cross checking DBCC IND and DBCC PAGE commands where i gone mad. Please help me out with the same.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)

Group: General Forum Members
Points: 831512 Visits: 48498
It shouldn't page split due to inserts. As you say, it's an increasing column and new rows will always be at the 'end'. The clustering key will be present, but as an include column (since that's a unique nonclustered index). It might be able to split due to updates through. What's the data type of the clustered index key, can it ever change?

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


Latheesh NK
Latheesh NK
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5161 Visits: 2164
Hi Gail, Thanks for your comments.

Still, am not clear on certain point:

The data type is BIGINT for both columns. The cluster index data will undergo many operations like insert,delete and update.

Could you please explain a scenario to understand the situation in better way plz...

" It might be able to split due to updates through." .
GilaMonster
GilaMonster
SSC Guru
SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)

Group: General Forum Members
Points: 831512 Visits: 48498
You can only get page splits due to updates if you're increasing the data stored in a variable-length column or updating a column from null to not null.

Can the clustered index key (that bigint) be null at all? If so, can it be updated from null to a not-null value?

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


Latheesh NK
Latheesh NK
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5161 Visits: 2164
Clustered index would not be null at all in my case. However, one point in my mind is that at the intermediate level due to page splits on clustered index (I read that the intermediate level would be a clustered Key rather then the case of heap), would it lead to a page split on non-clustered index even its a sequential one.

I can see the NextPageID of DBCC IND is far way from the CurrentPageID.However, its sequential.Can we take this scenario as a page split? Once I defragment, all Pages are getting closer and sequential.

Also I can see a small percentage of fragmentation in this case. Is this fragmentation due to any kind of Page split?If I could add a FILLFACTOR for the non-clustered index would it be beneficial to reduce the fragmentation?
GilaMonster
GilaMonster
SSC Guru
SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)SSC Guru (831K reputation)

Group: General Forum Members
Points: 831512 Visits: 48498
With a unique nonclustered index (which you have because it's the primary key) the clustering key won't be present at the intermediate level at all. It'll only be at the leaf level.

Why are you so worried about page splits?

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


Latheesh NK
Latheesh NK
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5161 Visits: 2164
Hi Gail,

Querying DMV, sys.dm db index operational stats, I can see some leaf allocation count and non leaf allocation count for these primary keys. In most of site, it refers a page split.

Answering your question"Why do you bother about page splits"
1. I would like to know the reason for the above count to understand the DMV. If the above are no way related to page splits, I would be able to take this DMV from my list to check the Page splits.

2. Even its not big; not claiming my db is perfect Smile, as long as these primary keys are no way in use of read operations, changing the fillfactor would benefit? I am curious to know the fact on the same.

3. Again, its small, if i could give some improvements in updates, if at al there any page splits, I would feel that I learnt something...

Thanks for your effort making me understand the things so far....
Latheesh NK
Latheesh NK
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5161 Visits: 2164
Can I look at the DMV for Page splits. Plz?
Latheesh NK
Latheesh NK
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5161 Visits: 2164
Appreciate any thoughts!!!
Latheesh NK
Latheesh NK
SSCertifiable
SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)SSCertifiable (5.2K reputation)

Group: General Forum Members
Points: 5161 Visits: 2164
Am I missing something in my question? Any thoughts?
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