0

I want to run exactly this command:

DBCC SHRINKDATABASE mydb

When I run this just for a while and then kill it, will the physical database file be a little bit smaller?

In other words: Does the command immediatedly free physical disk space during its run, or does it first a full reorganization, and only then free all physical space?

EDIT: We have simple recovery model, so our log file is very small and we only have one big database file.

1 Answer 1

2

DBCC SHRINKDATABASE does not rollback when the process is killed so theoretically you'd be able to run it for a period of a time, kill the process, and have some reclaimed space (assuming there is any that can be reclaimed). See this for more information.

Also please see and research the warnings I provided against shrinking in my answer to your other StackExchange question.

...[it's] heavy operations, generally nonsensical to do because if they grew to a certain size they'll likely grow back to that size soon anyway and a growth operation is also heavy, and shrinking any database files (except Temporary) does have a small risk of data corruption.

2
  • Thanks for the 1st paragraph. The 2nd paragraph does not apply to us. We had an abnormal operation which wasted space.
    – askolotl
    Dec 14, 2020 at 12:24
  • @askolotl No problem. I've been there (abnormal space wasting operation) and the experts still provided me the same warnings I'm passing on to you. I would be lying if I didn't say I still used the occasional shrink once in a blue moon anyway, but it's still important to be aware of the warnings, especially with potential data loss when shrinking the MDF.
    – J.D.
    Dec 14, 2020 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.