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

Solution - Decreasing initial datafile size of an user database Expand / Collapse
Author
Message
Posted Friday, October 7, 2011 2:27 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Today @ 3:38 AM
Points: 2, Visits: 182
The following issue occurred:
The datafile of the database has an initial size of 48GB while the data only occupies 29GB of the file.
DBCC SHRINKFILE only shrinks the MDF file to the initial size, but doesn't release the space held by the initial filesize or decreases the size of the datafile. Database files are not meant to be shrunk, however sometimes the "overhead" of free space claimed is not in scope with the size of the database.

Following steps solved the issue for me:
* Make a full database backup, of the database you want to change.
* Make sure you have sysadmin rights and bring the database into restricted user mode.
* Select tasks --> shrink --> files from the database menu.
* Choose the “Reorganize pages before...” option and enter the desired file size.
Make sure the file size is larger than the minimum needed space for the data.
* Check the properties of the database files and decrease the initial size of the datafile (if not already changed)
* After finishing bring the database back in Multi User mode.

This shrinks the files to the desired file size, without having to migrate data between datafiles (empty file solution) or having to bring the database or instance down.

As any DBA can tell you, be aware of (and know) what you're doing, before you start an action like this. It's not certain this will solve a similar issue for anyone else, but it's worth to investigate.
Post #1187384
Posted Saturday, October 8, 2011 12:15 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:48 PM
Points: 5,976, Visits: 12,887
.and then reindex your database, it will be badly fragmented following the shrink.


---------------------------------------------------------------------

Post #1187524
Posted Saturday, October 8, 2011 1:14 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Wednesday, July 23, 2014 12:40 AM
Points: 7,001, Visits: 8,439
arjen.schrier (10/7/2011)
The following issue occurred:
The datafile of the database has an initial size of 48GB while the data only occupies 29GB of the file.
DBCC SHRINKFILE only shrinks the MDF file to the initial size, but doesn't release the space held by the initial filesize or decreases the size of the datafile. Database files are not meant to be shrunk, however sometimes the "overhead" of free space claimed is not in scope with the size of the database.

Following steps solved the issue for me:
* Make a full database backup, of the database you want to change.
* Make sure you have sysadmin rights and bring the database into restricted user mode.

you only need to be db-owner group member for that !

* Select tasks --> shrink --> files from the database menu.
* Choose the “Reorganize pages before...” option and enter the desired file size.
Make sure the file size is larger than the minimum needed space for the data.
* Check the properties of the database files and decrease the initial size of the datafile (if not already changed)
* After finishing bring the database back in Multi User mode.

This shrinks the files to the desired file size, without having to migrate data between datafiles (empty file solution) or having to bring the database or instance down.

As any DBA can tell you, be aware of (and know) what you're doing, before you start an action like this. It's not certain this will solve a similar issue for anyone else, but it's worth to investigate.


As already mentioned, you should perform full db maintenance after a shrink operation !


Johan


Don't drive faster than your guardian angel can fly ...
but keeping both feet on the ground won't get you anywhere

- How to post Performance Problems
- How to post data/code to get the best help


- How to prevent a sore throat after hours of presenting ppt ?


"press F1 for solution", "press shift+F1 for urgent solution"


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me but most of the time this is me
Post #1187533
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse