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


Defragmenting a MDF file increasing allocated free space


Defragmenting a MDF file increasing allocated free space

Author
Message
Darren.Siegert
Darren.Siegert
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 25
My boss decided one of our databases which was performing fine was taking up too much space. His action was to run a shrink database command and then reduce the allocated free space by 50%.

The database is a reporting mart which gets loaded with approx 200,000 records every night. Before the above changes this load run for 2yrs and use to take 2hrs. Since the changes I have noticed the mdf file is badly fragmented and the load know takes between 8-10hrs.

How can I get back the allocated free space and defrag the mdf file? And do you think this will help with the performance issue?
GSquared
GSquared
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24259 Visits: 9730
Is the file having to grow in order to get the load done? That's the most likely cause of the slow-down.

- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread

"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
SA-1
SA-1
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1549 Visits: 944
The default trace should be able to help you find out if there are file growths (event class 92 and 93) during the data loads.
Darren.Siegert
Darren.Siegert
Forum Newbie
Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)Forum Newbie (8 reputation)

Group: General Forum Members
Points: 8 Visits: 25
Thanks I'll see if i can find the trace.

Its not somethinmg I have used before.
Jeffrey Williams 3188
Jeffrey Williams 3188
SSCertifiable
SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)SSCertifiable (8K reputation)

Group: General Forum Members
Points: 7983 Visits: 9971
To find out whether or not the data file is growing (autogrowths) you can use the Disk Usage report. Right-click on the database, go to reports and select the Disk Usage report. If you are not on SP2 or greater - the reports are in a different location but still accessible.

When the database was shrunk - all of your indexes were fragmented. I would schedule an index rebuild when you have the time, and make sure you have at least 1.5x the largest table available space in the data file. If not, manually grow the datafile so you do.

Jeffrey Williams
Problems are opportunities brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs

maechismo_8514
maechismo_8514
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: 1894 Visits: 2228
Darren.Siegert (3/26/2009)


The database is a reporting mart which gets loaded with approx 200,000 records every night.


With that kind of inserts I would drop and create them. Check the fragmentation levels after the inserts and then you can either decide to rebuild them or drop&create the indexes.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)SSC Guru (89K reputation)

Group: General Forum Members
Points: 89731 Visits: 45284
Darren.Siegert (3/26/2009)
His action was to run a shrink database command and then reduce the allocated free space by 50%.


Rebuild all of your indexes (perhaps after growing the file by 20% or so).

Shrinking causes massive fragmentation and will just result in the data file growing again next time data gets added. When that happens, the entire system will slow down as the file is expanded. Also repeated shrinks and grows will cause fragmentation at the file-system level, which is hard to fix.

See - http://sqlinthewild.co.za/index.php/2007/09/08/shrinking-databases/

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


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