views:

2194

answers:

1

When I shrink a sql server database using the GUI (All Tasks->Shrink Database->Accept all defaults, click OK), it finishes quickly.

But if I run this command, it takes a very very long time.

DBCC SHRINKDATABASE('my_database')

What am I missing?

This is in SQL Server 2000.

+1  A: 

If I recall correctly the interface will leave about 20% grown space, running DBCC SHRINKDATABASE without any parameters shrinks it to as small as possible.

I don't have Enterprise Manager handy to check the defaults. But you should notice a smaller database file with the manual run than the GUI run, thus the time difference

Mitchel Sellers
The gui default is actually to leave 0% free space.
JosephStyons
odd, mine is set to 20%, but who knows what happened there.
Mitchel Sellers
hm, maybe someone set it to 0% in the past and it saved the pref. anyway, it is fast in the gui and slow from Query Analyzer.
JosephStyons
doing some checking, I can't see anything that would support the difference, other than some potential optimization of the interface on the GUI side.
Mitchel Sellers
Well... upvote for the research, but I guess the Jury's still out on this one...
JosephStyons
Thanks, it is really odd, I'm googling far and wide, and I get nothing for sure. How much of a time difference are we talking?
Mitchel Sellers
From the GUI it took about 5 seconds, from Query Analyzer it was "go get a cup of coffee and chat with a co-worker" slow. Probably 15 mins or so.
JosephStyons