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

DB Shrinking Question Expand / Collapse
Author
Message
Posted Wednesday, January 16, 2013 9:09 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 28, 2013 2:25 PM
Points: 4, Visits: 10
First off, I'm no DBA just a server sys admin.

I run a maintenance plan on my Prod DBs every week that used to shrink the DBs but after doing some investigation I see that shrinking regularly is a very bad idea so I have removed shrinking from the plan. However I have a 55GB DB that has 10GB space available and the shrink from the maintenance plan (before I removed it) never seemed to free up the space. Backup times and space are a bit of an issue on the server so I'm trying clean up as much as I can. Why would the DB still be showing 10GB free space after a shrink?
Post #1408131
Posted Wednesday, January 16, 2013 9:30 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:46 PM
Points: 21,187, Visits: 14,880
Have you tried to manually shrink?

Also, after shrinking, did you also do an index defrag? Reindexing can cause the database to grow back out.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1408132
Posted Thursday, January 17, 2013 1:43 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, July 14, 2014 4:48 AM
Points: 2,834, Visits: 3,950
broonie27 (1/16/2013)
Why would the DB still be showing 10GB free space after a shrink?
From BOL If target_size is specified, DBCC SHRINKFILE tries to shrink the file to the specified size. Used pages in the part of the file to be freed are relocated to available free space in the part of the file retained. For example, if there is a 10-MB data file, a DBCC SHRINKFILE operations with a target_size of 8 causes all used pages in the last 2 MB of the file to be reallocated into any unallocated pages in the first 8 MB of the file. DBCC SHRINKFILE does not shrink a file past the size needed to store the data in the file. For example, if 7 MB of a 10-MB data file is used, a DBCC SHRINKFILE statement with a target_size of 6 shrinks the file to only 7 MB, not 6 MB.

See http://technet.microsoft.com/en-us/library/ms189493.aspx


-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1408214
Posted Thursday, January 17, 2013 12:22 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 28, 2013 2:25 PM
Points: 4, Visits: 10
The old maintenance plan, when it had the shrink task actually did a re-index before the shrink which I now know is very silly indeed.

I haven't actually manually run a shrink since I changed the maintenance plan but would it be an idea to a) Run a manual shrink and see what happens to the free space then b) run a manual re-index on the DB and see if the free space increases again?


Post #1408565
Posted Thursday, January 17, 2013 12:27 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:46 PM
Points: 21,187, Visits: 14,880
You could do that, but the index job will cause it to grow again.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1408566
Posted Thursday, January 17, 2013 12:29 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 28, 2013 2:25 PM
Points: 4, Visits: 10
Bhuvnesh (1/17/2013)
broonie27 (1/16/2013)
Why would the DB still be showing 10GB free space after a shrink?
From BOL If target_size is specified, DBCC SHRINKFILE tries to shrink the file to the specified size. Used pages in the part of the file to be freed are relocated to available free space in the part of the file retained. For example, if there is a 10-MB data file, a DBCC SHRINKFILE operations with a target_size of 8 causes all used pages in the last 2 MB of the file to be reallocated into any unallocated pages in the first 8 MB of the file. DBCC SHRINKFILE does not shrink a file past the size needed to store the data in the file. For example, if 7 MB of a 10-MB data file is used, a DBCC SHRINKFILE statement with a target_size of 6 shrinks the file to only 7 MB, not 6 MB.

See http://technet.microsoft.com/en-us/library/ms189493.aspx


No, I'm not running the task with target_size I don't think but it does run with the default of 10% of free space to remain after shrink. Maybe that is my problem?
Post #1408567
Posted Thursday, January 17, 2013 12:32 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, January 28, 2013 2:25 PM
Points: 4, Visits: 10
Not a good idea to do this during working hours I take it?
Post #1408568
Posted Thursday, January 17, 2013 12:33 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Yesterday @ 9:46 PM
Points: 21,187, Visits: 14,880
No. You should do it during a maintenance window or after business hours.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1408570
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse