Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Index maintenance

Author  Topic 

chris_cs
Posting Yak Master

223 Posts

Posted - 2008-11-18 : 11:28:15
I'm writing a script that will run periodically to re-build/re-organise all of the indexes in a database if required.

I have been told that to determine whether or not the Index should be re-built/re-organised I should look at the values for avg_fragmentation_in_percent and take the required action, also depending on whether the index is internal or external.

Could someone clarify what is meant by internal or external?

Thanks in advance

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2008-11-18 : 12:12:37
read it carefully resolve your confusion.
http://msdn.microsoft.com/en-us/library/ms189858.aspx
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-11-18 : 17:45:02
Internal Fragmentation: It is caused when pages are not full leading page splits which causes you to scroll through lot of pages

External Fragmentation: When pages are not in order and lots of pages have to be swapped back and forth to achieve required data.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-11-18 : 17:53:11
Well you could reinvent the wheel, or you could just use my script: http://weblogs.sqlteam.com/tarad/archive/2008/09/03/Defragmenting-Indexes-in-SQL-Server-2005.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

chris_cs
Posting Yak Master

223 Posts

Posted - 2008-11-19 : 06:12:49
Thanks all for the information.

It was most helpful.
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-11-19 : 07:12:06
You are welcome.

Average logical and Scan fragmentation you see are all External Fragmentation .
Go to Top of Page
   

- Advertisement -