SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Reduce database size


Reduce database size

Author
Message
Rynga
Rynga
Valued Member
Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)

Group: General Forum Members
Points: 71 Visits: 168
Have been asked by a customer to reduce the database size to latest 10% of its data. Not sure how to achieve this. Any help regarding this would be very useful. Thanks in advance.
Grant Fritchey
Grant Fritchey
SSC-Forever
SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)SSC-Forever (41K reputation)

Group: General Forum Members
Points: 41033 Visits: 32666
Your choices are pretty limited. You can remove data and then shrink the database. You can use storage compression if you're using Enterprise in SQL Server. You can look at a third party product like Red Gate SQL Storage Compress (disclosure, I work for Red Gate).

In general, simply saying, make the database smaller, is somewhat difficult to answer. Why do they need this. What are you trying to achieve? Is it just a storage issue or something else going on?

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Rynga
Rynga
Valued Member
Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)Valued Member (71 reputation)

Group: General Forum Members
Points: 71 Visits: 168
Its basically a storage issue and they are not in a position to expand the LUN being a UAT box
WolfgangE
WolfgangE
SSC-Addicted
SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)

Group: General Forum Members
Points: 489 Visits: 793
A further possibility could be hidden within the indexes. Do indexes have much fragmentation or are they reorganized regularly? Fragmented indexes can have a lot of impact on the their size .I have seen tables without doing maintenance for some weeks, after rebuilding they needed about 50 GB (!) less storage.
Another step could be to analyze index usage. If indexes are not used they should be dropped as they need storage space too. (Please don't start dropping indexes now, analyzing is a little bit of work :-D )

Another possibility is thinking of the storage type. If your storage is for hig availability it might be expensive. Is there data that can be moved to an archive? Could the archive be placed on an less expensive storage as the archive might be "less secure"?

Also check the size of the database log files and analyze if the size is really needed. Check if you can reduce log growing using a more frequently log backup.

Check the size of the database files too. A database file might have lots of storage reserved but only less of it actually used (maybe the file growed for example due to index rebuild operations). Try to shrink the file to an appropriate size.
Brandon Forest
Brandon Forest
SSC-Enthusiastic
SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)SSC-Enthusiastic (173 reputation)

Group: General Forum Members
Points: 173 Visits: 446
Grant is right about the indexes and transaction logs. Be sure the database is in simple mode, and run the DBCC ShrinkDatabase(<databasename>, 10) to recover any disk space that may be available from the log commitments. You mentioned that it is UAT. What are the testing requirements? Do you need to do a load test? Can you cull down the data, based on a date field? I just went throught this excercise on a development system. I asked our business users for the primary filter criteria, which turned out to be Member State. I applied a filter that focused on just 3 states for claims data. Once I deleted all the unwanted data and did a ShrinkDatabase, I reduced the database size on disk from 222GB to 74GB. w00t
WolfgangE
WolfgangE
SSC-Addicted
SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)SSC-Addicted (489 reputation)

Group: General Forum Members
Points: 489 Visits: 793
I would NOT recommend use SHRINKDB "just for fun". Of course is clears all unused disk space but it also can have it's negative impact, from maximum fragmented indexes to performance, as for some operations the file has to grow again.
Also setting recovery model to simple should be diskussed. It depends on how many data you lose if your system crashes. The full recovery model is no problem if you backup and thus empty the log file regularly.
Eric M Russell
Eric M Russell
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12473 Visits: 10691
ranganathleo (11/29/2012)
Have been asked by a customer to reduce the database size to latest 10% of its data. Not sure how to achieve this. Any help regarding this would be very useful. Thanks in advance.

Perhaps the easiest way to approach this disk space issue in UAT would be to periodically drop and restore the datbase from a backup.


"The universe is complicated and for the most part beyond your control, but your life is only as complicated as you choose it to be."
Lowell
Lowell
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28698 Visits: 39977
to get it to 10% of it's original size, that means deleting 90% of the data? i don't think that's what you are really asking.

besides the points above, (and compresison would be my first choice), find every table that is a HEAP, and put a clustered index on it; HEAP tables never release the space taken by deleted rows.

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

JimS-Indy
JimS-Indy
SSC-Addicted
SSC-Addicted (455 reputation)SSC-Addicted (455 reputation)SSC-Addicted (455 reputation)SSC-Addicted (455 reputation)SSC-Addicted (455 reputation)SSC-Addicted (455 reputation)SSC-Addicted (455 reputation)SSC-Addicted (455 reputation)

Group: General Forum Members
Points: 455 Visits: 444
Sorry, I'm a newbie. What's a 'LUN', and what's a 'UAT'?

Jim
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)SSC Guru (88K reputation)

Group: General Forum Members
Points: 88288 Visits: 41128
WolfgangE (12/3/2012)
I would NOT recommend use SHRINKDB "just for fun". Of course is clears all unused disk space but it also can have it's negative impact, from maximum fragmented indexes to performance, as for some operations the file has to grow again.
Also setting recovery model to simple should be diskussed. It depends on how many data you lose if your system crashes. The full recovery model is no problem if you backup and thus empty the log file regularly.


It is, however, a UAT box. Unless you're doing Point-in-time backups on your UAT box, there's no need to use any recovery mode other than SIMPLE. Also, a UAT box probably won't suffer the same amount of activity so it's not likely the log fie needs to be as large as the production box.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
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