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
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Evidence for Fragmentation

Author  Topic 

pdset
Constraint Violating Yak Guru

310 Posts

Posted - 2010-12-05 : 15:58:57
Hello Patrons,


Knowing that fragmenation causes as a result of the user transactions and other impediments.

But,

Will the Weekly Reindex job comprises any indirect Fragmentation as a result of the reindex?

I do have my weekly reindex job comprises the following aspects:

RECOMPILE STORED PROCEDURES;

UPDATE STATISTICS;

REINDEX on all tables.

CHECKDB on the database.



Thanks for your time.

Kristen
Test

22859 Posts

Posted - 2010-12-05 : 17:15:23
I don't think you need RECOMPILE STORED PROCEDURES - should happen automatically when you reindex / update statistics.

But if you do I would do if afterwards

My sequence would be

REINDEX on all tables (I would only do fragmented indexes)
UPDATE STATISTICS (only non-index stats required - beware if updating statistics on tables which ahve just been rebuilt if you are not using FULL SCAN)
RECOMPILE STORED PROCEDURES; (optional)
CHECKDB on the database.

Also: Restore backup to another machine, and do CHECKDB on that machine. If you do this then it is not necessary to also do CHECKDB on the main database - which can save some time on busy/large production servers / databases
Go to Top of Page

pdset
Constraint Violating Yak Guru

310 Posts

Posted - 2010-12-06 : 20:17:42
Thanks for the Reply.

However, Can I know how to negotiate in Reindex only those Fragmented indexes through the Script.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-06 : 23:46:28
pdset, you can use my custom script which intelligently decides what indexes "need" (depending upon the input parameters) to be defragmented and what options to use: http://weblogs.sqlteam.com/tarad/archive/2009/11/03/DefragmentingRebuilding-Indexes-in-SQL-Server-2005-and-2008Again.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

pdset
Constraint Violating Yak Guru

310 Posts

Posted - 2010-12-09 : 20:25:51
Thanks Tkizer. I have done with some exceptions as there won't be any results go beyond 100 rows of its execution output, though I have increased. This is due to I do have more than 100 tables.

Any flip to get all the results to its maximum.

Thanks again.
Go to Top of Page

pdset
Constraint Violating Yak Guru

310 Posts

Posted - 2010-12-09 : 20:27:56
Hi Tkizer,

Thanks for it. But I dont want Defragmenting everytime but only other than Defragmentation which is like Reindex.

Can this script be used for such purpose as well.

Thanks for your explanation and time.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-09 : 23:39:49
I don't understand either of your posts. But I'll see if I can answer them.

There is no limitation to the number of rows or number of tables.

My script can be used to rebuild/reindex or defragment/reorganize. It does both.

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

Subscribe to my blog
Go to Top of Page

pdset
Constraint Violating Yak Guru

310 Posts

Posted - 2010-12-10 : 00:05:53
I want to clarify what you haven't understood.

Your script exclusive for defragmenting / reindex based either rebuild or reorganize as you claim, which is good.

My interest here if I use script then I need not do everytime (on Weekly-Basis)defragmenting and so on.....

So I want to know whether your script NOT doing Defragmenting but only REINDEX on weekly basis.

Then still if I want at 'some juncture' to do Defragmenting will be good.

However, you have sounded this script is multi-faceted and I will try.

Perhaps this is much clear. Many thanks.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-12-10 : 02:29:48
Tara's script has parameters so you can control whether you want Re-index or De-fragment, and you can also set the amount of fragmentation - so only badly fragmented files will be processed.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-10 : 12:57:36
I'm going to do a huge rewrite soon that will allow you to do both rebuild and reorganize without having to call my sproc twice. It'll use Paul Randal's recommended values for each. I think I'll add an option to @defragType (or whatever it's called) that will allow you to pass in PBP (Paul's best practice).

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

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-10 : 12:59:33
Also, my rewrite will eliminate the @rowcount input variable and instead use @pagecount.

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

Subscribe to my blog
Go to Top of Page

pdset
Constraint Violating Yak Guru

310 Posts

Posted - 2010-12-13 : 23:21:29
Thanks TKizer for your overall support though I have executed on preliminary basis and to my astonishment I have seen the Largely populated tables still shows some fragmentation and I was not sure whether the Defragmentation has worked out or not.

Since all other tables got defragmented but the Large tables with almost 70 - 100 percent (before and after Defragmentation) was still existing.

On looking for answers what went wrong - I have got some answers that you have mentioned any fragmentation which has 1000 rows or less should be ignored. But in my case it is not so, (bottomline users didn't complain of slowness for which fragmentation was one of the reasons).

Do I need to understand the defragmentation has worked.

If so, What other measures need to look into.

Thanks for elaborating for my cause perhaps it is most of DBA's still look for similar answers like this.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-12-13 : 23:54:53
Fragmentation is normal on small tables. On those that you've noticed fragmentation exists after you've rebuilt the indexes, how many pages are there in those indexes?

Row counts don't really matter. It's page count that matters. It's around 1,000 pages that matters, but Paul Randal indicates it might be as high as 10,000 pages.

Also, you may have a system with heavy fragmentation due to improper clustered index. On the table with the problem what's the clustered index (data type and columns, please).

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

Subscribe to my blog
Go to Top of Page
   

- Advertisement -