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


Index Fragmentation and Performance


Index Fragmentation and Performance

Author
Message
SQLSACT
SQLSACT
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2106 Visits: 2931
Hi All

I understand that External Fragmentation exists when the Index pages are not in a logical order for SQL Server to read.

I also understand that Internal Fragmentation is when the Index pages are not filled to capacity.

Given that you will only see performance degradation on an Index with lots of External fragmentation with Range Scan queries

Is it safe to say that Internal fragmentation will never result in a performance degradation?


Thanks
laurie-789651
laurie-789651
SSChasing Mays
SSChasing Mays (618 reputation)SSChasing Mays (618 reputation)SSChasing Mays (618 reputation)SSChasing Mays (618 reputation)SSChasing Mays (618 reputation)SSChasing Mays (618 reputation)SSChasing Mays (618 reputation)SSChasing Mays (618 reputation)

Group: General Forum Members
Points: 618 Visits: 1272
The less full index pages are, the more of them must be read into memory to do a given search. The fuller they are, the less pages need to be read - so there is a performance hit.

For maximum efficiency, you should use fill factor = 100% - but this only works for read-only tables, otherwise you get page splits.

So for updateable tables you need to find a balance, & rebuild the indexes from time to time.
pooyan_pdm
pooyan_pdm
SSC-Enthusiastic
SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)

Group: General Forum Members
Points: 194 Visits: 422
you should specify the fill-factor for an index based on the number of inserts,updates on the index key(s) and the size of the index key(s) the more inserts on the index the less the fill-factor should be and the bigger the index key perhaps you should choose a smaller fill-factor but for sure there is a trade-off .you should check the external fragmentation over time to come up with a appropriate value for fill-factor

Pooyan
Alexander Suprun
Alexander Suprun
Mr or Mrs. 500
Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)

Group: General Forum Members
Points: 517 Visits: 1516
pooyan_pdm (8/8/2012)
you should specify the fill-factor for an index based on the number of inserts,
Wrong

updates on the index key(s)
Not only updates on the index key can cause fragmentation

the more inserts on the index the less the fill-factor should be
Wrong again. E.g. an insert into an ever-increasing index will never lead to fragmentation. Or an insert into an index with several static key values won't create fragmentation either.

My advice is if one doesn't fully understand what is fill-factor and the patterns of updating data in the given database then it's better to leave fill-factor to default value, otherwise the harm may outweigh all the benefits.


Alex Suprun
pooyan_pdm
pooyan_pdm
SSC-Enthusiastic
SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)SSC-Enthusiastic (194 reputation)

Group: General Forum Members
Points: 194 Visits: 422
What I said is a general guidline and is true, yes with a ever increasing key the inserts does not cause the fragmentation but generally speaking beacuse most of the times there is no trend in inserting the key values the more the inserts the more page splits and fragmentation . And about the update I don't know what you think of a index key update but it' effects on page splits and fragmentation is the same as another insert.

Pooyan
SQLSACT
SQLSACT
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2106 Visits: 2931
Thanks Guys!!
Alexander Suprun
Alexander Suprun
Mr or Mrs. 500
Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)Mr or Mrs. 500 (517 reputation)

Group: General Forum Members
Points: 517 Visits: 1516
pooyan_pdm (8/8/2012)
What I said is a general guidline and is true, yes with a ever increasing key the inserts does not cause the fragmentation but generally speaking beacuse most of the times there is no trend in inserting the key values the more the inserts the more page splits and fragmentation . And about the update I don't know what you think of a index key update but it' effects on page splits and fragmentation is the same as another insert.
I've seen the cases where people using general guideline set fill-factors to 70% which instantly leads to performance degradation by 30% while the benefits of doing that are really questionable.


Alex Suprun
GilaMonster
GilaMonster
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88240 Visits: 45277
pooyan_pdm (8/8/2012)
And about the update I don't know what you think of a index key update but it' effects on page splits and fragmentation is the same as another insert.


An update can only cause page splits in an index if it increases the size of the columns used as key or include. That's null-> non-null or increasing the amount of data in a variable length column.

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


SQLSACT
SQLSACT
SSCrazy
SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)SSCrazy (2.1K reputation)

Group: General Forum Members
Points: 2106 Visits: 2931
GilaMonster (8/10/2012)
pooyan_pdm (8/8/2012)
And about the update I don't know what you think of a index key update but it' effects on page splits and fragmentation is the same as another insert.


An update can only cause page splits in an index if it increases the size of the columns used as key or include. That's null-> non-null or increasing the amount of data in a variable length column.


Thanks

Regarding tracking page-splits, is this represented by the leaf_allocation_count in the sys.dm_db_index_operational_stats DMV?

Thanks
GilaMonster
GilaMonster
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88240 Visits: 45277
No. That's literally the number of pages that were allocated, middle or end. Tracking mid-index page splits (which are the harmful ones) is near-impossible until SQL 2012.

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


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