SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Index Defrag
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Shastryv
Posting Yak Master

USA
145 Posts

Posted - 08/26/2005 :  09:31:03  Show Profile  Visit Shastryv's Homepage  Send Shastryv an AOL message  Send Shastryv a Yahoo! Message  Reply with Quote
I am just curious how many of you agree/disagree on this. Your input is appreciated.

It's about index defrag. Would you normally check the de fragmentation using Showcontig and then rebuild/defrag the index or directly rebuild/defrag index with out running the showcontig. I prefer the first one, rebuild indexes, showcontig is waste of time to me.

Thanks



SamC
White Water Yakist

USA
3453 Posts

Posted - 08/26/2005 :  09:48:22  Show Profile  Reply with Quote
I agree, but it depends on whether you have a huge honkin' table that takes an hour to defrag. You might not want to defrag it unless it was necessary.
Go to Top of Page

Thrasymachus
Constraint Violating Yak Guru

USA
483 Posts

Posted - 08/26/2005 :  09:55:46  Show Profile  Reply with Quote
I like this.

http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx

====================================================
Regards,
Sean Roussy

"pimpin ain't easy, but someone has to do it" -- Pimpin Whitefolks(?)
Go to Top of Page

Kristen
Test

United Kingdom
19300 Posts

Posted - 08/27/2005 :  02:05:45  Show Profile  Reply with Quote
We defrag if the index is large, otherwise reindex. But only if the index is bigger than a small-thing (I forget exactly, but some really small tables appeared frag'd immediatly after reindex), and is more than 20% fragmentated.

Our DBs are 24/7, so we need a minimally-invasive strategy. Otherwise you could just reindex the lot, but you'll take a hit on log size / disk space.

Kristen
Go to Top of Page

paulrandal
Aged Yak Warrior

USA
897 Posts

Posted - 08/27/2005 :  10:31:34  Show Profile  Visit paulrandal's Homepage  Reply with Quote
quote:
Originally posted by Kristen
...but some really small tables appeared frag'd immediatly after reindex), and is more than 20% fragmentated.



Logical scan fragmentation?

Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
Go to Top of Page

paulrandal
Aged Yak Warrior

USA
897 Posts

Posted - 08/27/2005 :  10:35:40  Show Profile  Visit paulrandal's Homepage  Reply with Quote
quote:
Originally posted by Shastryv

I am just curious how many of you agree/disagree on this. Your input is appreciated.

It's about index defrag. Would you normally check the de fragmentation using Showcontig and then rebuild/defrag the index or directly rebuild/defrag index with out running the showcontig. I prefer the first one, rebuild indexes, showcontig is waste of time to me.

Thanks



You should definitely read the whitepaper. In a nutshell - don't remove fragmentation unless you have to otherwise you're wasting resources. My main reason for writing the DBCC INDEXDEFRAG command was to give an online way of removing fragmentation but it has a high cost in transaction log and it can't update statistics - that's the trade-off you make when comparing with DBCC DBREINDEX.

And don't base your decision on Scan Density or Extent Fragmentation - always use Logical Fragmentation.

Regards

Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
Go to Top of Page

Kristen
Test

United Kingdom
19300 Posts

Posted - 08/28/2005 :  03:01:58  Show Profile  Reply with Quote
"Logical scan fragmentation?"

Doesn't look like it, no :-(

I'm making a temporary table from the results of:

DBCC SHOWCONTIG (@MyTableID) WITH FAST, TABLERESULTS, ALL_INDEXES, NO_INFOMSGS

I'm then rebuilding where:

    ScanDensity <= 90
AND INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') > 0
AND CountPages > 10


If CountPages < 10000 I rebuild, otherwise I defrag (we have an override to periodically force Reindex on the bigger indexes)

Kristen
Go to Top of Page

paulrandal
Aged Yak Warrior

USA
897 Posts

Posted - 08/28/2005 :  10:47:34  Show Profile  Visit paulrandal's Homepage  Reply with Quote
quote:
Originally posted by Kristen

"Logical scan fragmentation?"

Doesn't look like it, no :-(

I'm making a temporary table from the results of:

DBCC SHOWCONTIG (@MyTableID) WITH FAST, TABLERESULTS, ALL_INDEXES, NO_INFOMSGS

I'm then rebuilding where:

    ScanDensity <= 90
AND INDEXPROPERTY (ObjectId, IndexName, 'IndexDepth') > 0
AND CountPages > 10


If CountPages < 10000 I rebuild, otherwise I defrag (we have an override to periodically force Reindex on the bigger indexes)

Kristen



Do you have multiple files in your filegroups? If so, Scan Density doesn't work and you need to use Logical Scan Fragmentation as your trigger.

Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
Go to Top of Page

Kristen
Test

United Kingdom
19300 Posts

Posted - 08/29/2005 :  05:58:26  Show Profile  Reply with Quote
"Do you have multiple files in your filegroups"

No, but we might easily do in the future.

What level should I set for logical fragementation? Persumably its pointless defragging for just the odd one or two fragemented blocks in a large file?

So if I'm currently using ScanDensity <= 90 would LogicalFrag > 10 be a good plan?

Checking my logs I find I am currently rebuilding lots of tables/indexes where ScanDensity is around 50 - 70, but the LogicalFrag is <10, and in many case 0.

Kristen
Go to Top of Page

paulrandal
Aged Yak Warrior

USA
897 Posts

Posted - 08/29/2005 :  12:30:30  Show Profile  Visit paulrandal's Homepage  Reply with Quote
quote:
Originally posted by Kristen

"Do you have multiple files in your filegroups"

No, but we might easily do in the future.

What level should I set for logical fragementation? Persumably its pointless defragging for just the odd one or two fragemented blocks in a large file?

So if I'm currently using ScanDensity <= 90 would LogicalFrag > 10 be a good plan?

Checking my logs I find I am currently rebuilding lots of tables/indexes where ScanDensity is around 50 - 70, but the LogicalFrag is <10, and in many case 0.

Kristen



It depends. Unless you've actually correlated increasing fragmentation with decreasing performance, there's no point removing fragmentation. To pick the threshold to use, you need to get some empirical data to help you decide. 10% fragmentation may have negligible effect on your performance, for instance. The whitepaper has a bunch of info on doing this.

Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
Go to Top of Page

SQLServerDBA_Dan
Aged Yak Warrior

USA
751 Posts

Posted - 08/29/2005 :  16:39:02  Show Profile  Reply with Quote
quote:
Originally posted by paulrandal
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)



I think that pretty much sums up the post... I guess I'll need to review the white paper that you're speaking of because I don't understand how fragmentation would be ok or not degradate performance. If you're looking up data and SQL Server has to get pointers to go to other pages that then have pointers to other pages which also have pointers to the pages that actually contain the data that has to be slower at least by a nano second.

Daniel
SQL Server DBA
www.dallasteam.com
Go to Top of Page

nduckste
Starting Member

USA
2 Posts

Posted - 11/30/2006 :  18:43:45  Show Profile  Reply with Quote
Paul,

Is there you could explain ScanDensity and Extent Fragmentation -- or point me to an article where it is already explained. There are some on our team that say ScanDensity is a better measure for determinining fragmentation but I don't have a good explanation why.

Thanks,

Nick

quote:
Originally posted by paulrandal

quote:
Originally posted by Shastryv

I am just curious how many of you agree/disagree on this. Your input is appreciated.

It's about index defrag. Would you normally check the de fragmentation using Showcontig and then rebuild/defrag the index or directly rebuild/defrag index with out running the showcontig. I prefer the first one, rebuild indexes, showcontig is waste of time to me.

Thanks



You should definitely read the whitepaper. In a nutshell - don't remove fragmentation unless you have to otherwise you're wasting resources. My main reason for writing the DBCC INDEXDEFRAG command was to give an online way of removing fragmentation but it has a high cost in transaction log and it can't update statistics - that's the trade-off you make when comparing with DBCC DBREINDEX.

And don't base your decision on Scan Density or Extent Fragmentation - always use Logical Fragmentation.

Regards

Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000 Version 3.4.03