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


Trying to understand non-clustered index Fragmentation


Trying to understand non-clustered index Fragmentation

Author
Message
GilaMonster
GilaMonster
SSC Guru
SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)

Group: General Forum Members
Points: 218909 Visits: 46279
Robert Davis (1/22/2013)
There must simply not be enough contiguous free space for it to rebuild it unfragmented.


I've seen indexes rebuild fragmented before, but never this bad.

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


LAW1143
LAW1143
SSC-Addicted
SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)

Group: General Forum Members
Points: 478 Visits: 421
There was 10gb free in the data file. I was thinking in that direction myself.

219k pages @ 8k/page = 1,752,000 kb = 1.7gb... I just added a few gb more and will try the rebuild again and see what gives...

thanks!
LAW1143
LAW1143
SSC-Addicted
SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)

Group: General Forum Members
Points: 478 Visits: 421
Doh, there we go... attachments!

scroll bar is my friend w00t
Attachments
Fragmentation.jpg (33 views, 38.00 KB)
LAW1143
LAW1143
SSC-Addicted
SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)

Group: General Forum Members
Points: 478 Visits: 421
I added 20gb to the data file, and immediately ran the rebuild.

same, 94.1932% avg_fragmentation_in_percent...

might this have anything to do with the datatypes of the index columns?

also, my first post had an inaccuracy in it. the non-clustered index is based on TWO big-ints and a datetime, not one...
Robert Davis
Robert Davis
SSCertifiable
SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)SSCertifiable (6.5K reputation)

Group: General Forum Members
Points: 6464 Visits: 1632
GilaMonster (1/22/2013)
I've seen indexes rebuild fragmented before, but never this bad.


Same here.



My blog: SQL Soldier
Twitter: @SQLSoldier
My book: Pro SQL Server 2008 Mirroring
Microsoft Certified Master, SQL Server MVP
Database Engineer at BlueMountain Capital Management
GilaMonster
GilaMonster
SSC Guru
SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)SSC Guru (218K reputation)

Group: General Forum Members
Points: 218909 Visits: 46279
LAW1143 (1/22/2013)
might this have anything to do with the datatypes of the index columns?


No. Nothing strange about bigint columns.

Just checking... You are rebuilding the same index that you're checking (same table, same database, same server)? Not trying to be insulting, but I've seen many times people working on different servers without realising.

Can you post the table and index definitions?

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


LAW1143
LAW1143
SSC-Addicted
SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)

Group: General Forum Members
Points: 478 Visits: 421
The highlighted index is the one we're dealing with...

and I'm not above making stupid mistakes... in fact, I usually dont recognize them as such untill I post here or ask someone else to explain something that doesnt make sense...

I just double (er, triple) checked, and im looking at the right server, db, table, index statistics as the one im rebuilding...

thanks again for your time and help! Smile
Attachments
tableDef.jpg (26 views, 129.00 KB)
LAW1143
LAW1143
SSC-Addicted
SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)

Group: General Forum Members
Points: 478 Visits: 421
Final update of the day from me... my brain hurts and im going home...

I just did a Alter Index ALL on this table to see what came of it...

Index_id 11 is my problem child:

index_id avg_fragmentation_in_percent
1 0.179520838203473
2 0.532145960034752
4 0.518418036320809
11 93.7920077651411
16 0.89879248101581

Crazy
LAW1143
LAW1143
SSC-Addicted
SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)SSC-Addicted (478 reputation)

Group: General Forum Members
Points: 478 Visits: 421
I did a quick comparison against a few other databases (of varying sizes) with the same table/index definitions and found similar results..

short term, I'll just exclude this from the automated indexing routine i am working up, but I'd still like to understand why this index is so fragmented, even immediately after a rebuild.

thanks again for everyone's help and time!: )
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