Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Solution - Decreasing initial datafile size of an user database


Solution - Decreasing initial datafile size of an user database

Author
Message
arjen.schrier
arjen.schrier
Forum Newbie
Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: General Forum Members
Points: 2 Visits: 209
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.
george sibbald
george sibbald
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6324 Visits: 13687
.and then reindex your database, it will be badly fragmented following the shrink.

---------------------------------------------------------------------
ALZDBA
ALZDBA
SSCertifiable
SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)SSCertifiable (7K reputation)

Group: General Forum Members
Points: 6972 Visits: 8839
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 w00t

- 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" :-D


Need a bit of Powershell? How about this

Who am I ? Sometimes this is me Alien but most of the time this is me Hehe
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