Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Index rebuild fragmentation criteria confusion Expand / Collapse
Author
Message
Posted Saturday, January 5, 2013 7:09 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 2:17 PM
Points: 424, Visits: 1,562
There is tons of info regarding selective index rebuild/reorganize (with magic numbers 10-30%) depending on output of DMV sys.dm_db_index_physical_stats. But I confused with what particular values from this DMV I should use for my index rebuild
procedure?
I mean some sources (BOL script example, etc) suggest to use avg_fragmentation_in_percent only (i.e. external fragmentation- EF), others- to add internal fragmentation (IF) value also- if avg_page_space_used_in_percent is less than 75%- it's bad.
Let say I consider only indexes with size 1000+ pages

Really appreciate help in clarifying this issue- EF or EF + IF?
Mainly I am interested in- Why?
Thanks
Post #1403300
Posted Saturday, January 5, 2013 8:41 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 9:28 PM
Points: 17,729, Visits: 15,597
You should consider the page density (Internal Frag) in addition to the External Fragmentation. And the value to consider for internal frag depends on your data and page density settings. If you have not altered your fillfactor from the default and you have avg_page_space_used of 75% and 1000 pages, you have incurred about an extra 250 pages. If you then need to scan the table you can be looking at that much more processing that needs to be done.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1403302
Posted Saturday, January 5, 2013 9:32 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 2:17 PM
Points: 424, Visits: 1,562
It makes sense to consider internal fragmentation while making decision to rebuild indexes- why in this case majority scripts/advices (including mentioned BOL sample) do not care about it (only external one)? Thanks
Post #1403304
Posted Sunday, January 6, 2013 12:34 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, September 29, 2014 5:01 AM
Points: 2,840, Visits: 3,968
what i think here , external fragmentation is basically handled by sql server internally and data get inserted in mixed extent initially (i think we can keep "table having identity col's PK" out here ) later on data moves into contigous extent. this could be reason why external fragmentation get avoided.

I welcome comments here


-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1403308
Posted Sunday, January 6, 2013 2:04 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 7:59 AM
Points: 39,984, Visits: 36,353
Yuri55 (1/5/2013)
It makes sense to consider internal fragmentation while making decision to rebuild indexes- why in this case majority scripts/advices (including mentioned BOL sample) do not care about it (only external one)? Thanks


Because it's easier.
Because most of the recommendations (which date back years if not decades) look at logical fragmentation only.

p.s. Internal and External fragmentation can be confusing terms, depending what the internal and external refer to. Easier and less prone to misunderstandings to call them logical fragmentation and low page density.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1403314
Posted Sunday, January 6, 2013 2:07 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 7:59 AM
Points: 39,984, Visits: 36,353
Bhuvnesh (1/6/2013)
external fragmentation is basically handled by sql server internally


No, it's not. Fixing 'external fragmentation' requires an index rebuild or index reorganise.

and data get inserted in mixed extent initially (i think we can keep "table having identity col's PK" out here ) later on data moves into contigous extent. this could be reason why external fragmentation get avoided.


The external fragmentation he's talking about is not extent fragmentation. It's logical fragmentation, pages having their physical order not matching their logical order.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
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

Post #1403315
Posted Sunday, January 6, 2013 7:24 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: 2 days ago @ 2:17 PM
Points: 424, Visits: 1,562
Thanks guys for all your answers-
just to summarize- for index maintenance we need to take into account both logical fragmentation and page density. Still have couple questions left: 1) index size 1000+ pages recommendation for any action- valid for ReBuild and ReOrganize? 2) page density below 75%- index Rebuild or Reorganize?
Thanks
Post #1403330
Posted Sunday, January 13, 2013 3:31 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 7:44 PM
Points: 7,107, Visits: 12,661
Yuri55 (1/6/2013)
Thanks guys for all your answers-
just to summarize- for index maintenance we need to take into account both logical fragmentation and page density. Still have couple questions left:
1) index size 1000+ pages recommendation for any action- valid for ReBuild and ReOrganize?

If it is below 1000 pages chances are index maintenance will not make much difference so most of the scripts out there skip those smaller indexes regardless of the fragmentation level.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1406519
Posted Sunday, January 13, 2013 3:43 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 7:44 PM
Points: 7,107, Visits: 12,661
2) page density below 75%- index Rebuild or Reorganize?

It depends on the fillfactor. If you chose 80% you may not want to perform maintenance if page density is at 75%.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1406523
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse