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


shrinkdatabase taking looooong time


shrinkdatabase taking looooong time

Author
Message
Sailor
Sailor
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4216 Visits: 866
I have a db that has one 58 gig data file. The server it was housed on finally ran out of disk space due to this app. I moved stuff off for several years to attempt to keep the app running. The end users have finally agreed to deleting data. After deleting, the data is occupying 35 gig out of the 58. There are numerous indexes, occpuying easily 1/3 of the data file. I started to shrink it. I ran a shrink db ('dbdata',15). As there is not enough room on that server, I moved the db to a new server (3.2 ghz, 4 gig ram, 10,000 RPM RAID 5 drives (300 GIGS)). I have been running shrinkdb for 22 hours. I've been watching activity and saw its has page io latch and the numbers are changing. There is no other activity on the server, I even turned off sql agent. Is this normal for it to take this long?

The server is primarily used as a spare where I restore databases to.



Carl Federl
Carl Federl
SSC-Insane
SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)SSC-Insane (22K reputation)

Group: General Forum Members
Points: 22842 Visits: 4355
With 10,000 RPM RAID 5 drives, yes, this will run for a very long time. Do not be suprised if the run time exceeds 40 hours.

Recommend:
15K RPM drives
36Gb drives - no larger

For the transaction log, use dedicated RAID-1 disks and do not stripe. If the transaction log needs to be larger than the 36Gb, have 2 seperate sets of disk and have multiple files for the transaction log.

For the data files, expect to use a maximum of 80% of the space for data files. Stripping the disk may or may not work.

You also may need to put tempdb on its own disk.

SQL = Scarcely Qualifies as a Language
MohammedU
MohammedU
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17280 Visits: 812

Some times it may take many hours...

If you have LOB in your db... it may not shrink at all...see the following article...

DBCC SHRINKFILE and SHRINKDATABASE commands may not work because of sparsely populated text, ntext, or image columns

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



MohammedU
Microsoft SQL Server MVP
barsuk
barsuk
SSChampion
SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)SSChampion (10K reputation)

Group: General Forum Members
Points: 10719 Visits: 7836
use DBCC SHRINKFILE instead of SHRINKDATABASE



Sailor
Sailor
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4216 Visits: 866
thanks for all the info.

I ran shrinkdatabase and it still wasn't finished after 42 hours. I had to stop it to get the app up and running again. I tried shrinkfile previously and this wasn't going faster either after 26 hours.

For the hardware suggestion, that's always something to aim for, but I don't think we'll ever get it.

If I eventually try again, do I need to have equivalent disk space free (ie 58 gig) or could I run it with 8 to 10 gig free?



Todd Stu
Todd Stu
SSC-Addicted
SSC-Addicted (468 reputation)SSC-Addicted (468 reputation)SSC-Addicted (468 reputation)SSC-Addicted (468 reputation)SSC-Addicted (468 reputation)SSC-Addicted (468 reputation)SSC-Addicted (468 reputation)SSC-Addicted (468 reputation)

Group: General Forum Members
Points: 468 Visits: 254

try reindexing the tables.

if you deleted data the indexes are probably very fragmented.




Cheers,

Todd

Sailor
Sailor
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4216 Visits: 866
Indexes were actually dropped and rebuilt a week ago. There are daily bulk inserts, so it's possible they need defragging weekly.



ShekharNaidu
ShekharNaidu
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1806 Visits: 70

You have transaction log and DB backups running daily..??

try backing up them and shrink..




Thanks ,

Shekhar

John Mitchell-245523
John Mitchell-245523
SSC Guru
SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)SSC Guru (129K reputation)

Group: General Forum Members
Points: 129489 Visits: 18964

Do you really need to shrink at all? It sounds like you have plenty of disk space... are you doing this to free up space for something else? If not, bear in mind that shrinking consumes system resources (as you are seeing) and can cause disk fragmentation.

John


rhamnusia
rhamnusia
SSC Veteran
SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)

Group: General Forum Members
Points: 260 Visits: 322

You might try the brute force method: Create a new database on the 'spare' server and then your tables - avoid the indexes and triggers if you can. bcp the data from your production database to the 'spare' server. Once completed, install your other objects - triggers, procs, etc. Backup the new database, verify all objects between db's, drop the old database, and then restore the new database onto your production system and rebuild the indexes.

Ugly solution, but if you're in a pinch...


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