Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Defragmenting a MDF file increasing allocated free space Expand / Collapse
Author
Message
Posted Thursday, March 26, 2009 8:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 1, 2009 2:30 AM
Points: 4, 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?
Post #684190
Posted Thursday, March 26, 2009 8:37 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Friday, June 27, 2014 12:43 PM
Points: 15,444, Visits: 9,596
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
Post #684201
Posted Thursday, March 26, 2009 8:43 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, January 29, 2014 2:58 PM
Points: 1,141, 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.
Post #684207
Posted Thursday, March 26, 2009 9:02 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, May 1, 2009 2:30 AM
Points: 4, Visits: 25
Thanks I'll see if i can find the trace.

Its not somethinmg I have used before.
Post #684234
Posted Thursday, March 26, 2009 12:22 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Friday, July 25, 2014 3:48 PM
Points: 4,388, Visits: 9,506
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 opportunites brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs
Post #684471
Posted Thursday, March 26, 2009 12:58 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, August 24, 2012 8:11 AM
Points: 1,097, Visits: 2,157
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.
Post #684505
Posted Thursday, March 26, 2009 1:45 PM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:46 PM
Points: 42,462, Visits: 35,525
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 2008, MVP
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

Post #684552
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse