?
Solved

Shrinking databsae

Posted on 2012-08-27
12
Medium Priority
?
568 Views
Last Modified: 2012-09-21
I have a database more than 600GB using simple recovery mode. It has smaller log file size. I want to shrink it. But I suspect that might break down the database.

My question is if it will damage the database if I shrink a large database like 600 GB? What is the risky point for doing that?

Also, I see the tempdb has big log size, Can I shrink the tembdb? what is the risky point for doing that?
0
Comment
Question by:wasabi3689
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 10

Accepted Solution

by:
djcanter earned 472 total points
ID: 38336922
Shrink DB should not allow you to truncate data, it should only purge free space.
The temp db will also be shrunk after recycling the SQL instance.
0
 
LVL 59

Assisted Solution

by:Darius Ghassem
Darius Ghassem earned 472 total points
ID: 38336935
Shrinking the DB will not cause any issues I would recommend doing it during off hours.

TempDB will go back down to 8MB when you restart the SQL Server instance
0
 
LVL 11

Assisted Solution

by:TheGeezer2010
TheGeezer2010 earned 704 total points
ID: 38336943
DO NOT shrink a database to get back space.

It causes MASSIVE index fragmentation

I am not going to post all the reasons but suffice to say the following link contains other links showing :-

1. The problems caused by shrinking
2. What you can do INSTEAD of shrinking

http://www.brentozar.com/archive/2009/08/stop-shrinking-your-database-files-seriously-now/

Shrinking TempDB is possible, but you must make sure it is not in use. Following Microsoft article details two methods :-

http://support.microsoft.com/kb/307487

Hope this was useful !!
0
Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

 

Author Comment

by:wasabi3689
ID: 38336979
djcanter say will not cause any issue.

TheGeezer2010 say it may be useless?

What is the key here? The purpose for me to shrink DB is to get space
0
 
LVL 11

Assisted Solution

by:TheGeezer2010
TheGeezer2010 earned 704 total points
ID: 38337027
The issue you will get is potentially a huge performance issue until/unless you follow the article showing how to defrag the index/
0
 

Author Comment

by:wasabi3689
ID: 38337057
I already have performance issue. Do you mean it will not help if I shrink the database to get more space?
0
 
LVL 10

Assisted Solution

by:djcanter
djcanter earned 472 total points
ID: 38337161
I stated that the shrink will not truncate data.  Geezer is absolutely correct that you should not need to shrink the database. If you look at the properties/ filesize of the database, there likely is not a lot of freespace in the DB to shrink.  If storage is the concern, you can migrate the dbs and logs to new respective drives.
0
 
LVL 59

Assisted Solution

by:Darius Ghassem
Darius Ghassem earned 472 total points
ID: 38337447
Shrinking the database should not be a regular maintenance procedure but it can be done and sometimes should be done. There are other procedures that should be run after the shrink command like rebuilding indexes which will help with performance in the long and run and update the DB stats
0
 

Author Comment

by:wasabi3689
ID: 38338086
I see Task->Shrink-> Data, I see if I shrink

Currently allocated space: 604818.38 MB

Available free space :333759.97 MB (55%)

Does it mean if I shrink the db, I will have 55% free up for the database, is this the benefit I should go?
0
 
LVL 11

Assisted Solution

by:TheGeezer2010
TheGeezer2010 earned 704 total points
ID: 38338439
I cannot help you further as the links I have sent you gave you an alternative way to achieve the same thing. It also points out that good practice is to alter the growth default settings when creating the database - the default settings are usually not ideal for most databases and can lead to database sprawl and performance issues as it grows.
If you are intent on doing this, please ensure you have a good backup tested as working, do it out of hours, and ensure you follow the post-shrink instructions regarding index defragmentation. I wish you good luck  !
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 232 total points
ID: 38339192
Does it mean if I shrink the db, I will have 55% free up for the database, is this the benefit I should go?
Define "benefit".  If it is improved performance, than shrinking the database alone, will have exactly the opposite effect, as has been pointed out to you repeatedly.  But the best way to learn, is for you to go ahead and shrink your database.  Later on when you realize it had no effect on performance and if anything made things worse, you will understand.  Hopefully it will not be too late and you don't have to update your resume...

Good luck.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
SQL Database Recovery Software repairs the MDF & NDF Files, corrupted due to hardware related issues or software related errors. Provides preview of recovered database objects and allows saving in either MSSQL, CSV, HTML or XLS format. Ensures recov…
Stellar Phoenix SQL Database Repair software easily fixes the suspect mode issue of SQL Server database. It is a simple process to bring the database from suspect mode to normal mode. Check out the video and fix the SQL database suspect mode problem.

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question