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


Index rebuild fragmentation criteria confusion


Index rebuild fragmentation criteria confusion

Author
Message
Yuri55
Yuri55
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1874 Visits: 2056
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
SQLRNNR
SQLRNNR
SSC Guru
SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)SSC Guru (65K reputation)

Group: General Forum Members
Points: 65855 Visits: 18570
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, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw

Yuri55
Yuri55
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1874 Visits: 2056
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
Bhuvnesh
Bhuvnesh
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13080 Visits: 4077
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;-)
GilaMonster
GilaMonster
SSC Guru
SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)

Group: General Forum Members
Points: 221243 Visits: 46279
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, 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


GilaMonster
GilaMonster
SSC Guru
SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)SSC Guru (221K reputation)

Group: General Forum Members
Points: 221243 Visits: 46279
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, 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


Yuri55
Yuri55
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1874 Visits: 2056
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
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39006 Visits: 14411
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
Orlando Colamatteo
Orlando Colamatteo
SSC-Dedicated
SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)SSC-Dedicated (39K reputation)

Group: General Forum Members
Points: 39006 Visits: 14411
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
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