DB Shrinking Question

  • 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?

  • 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, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • 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;-)

  • 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?

  • 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, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • 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?

  • Not a good idea to do this during working hours I take it?

  • 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, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply