0

In the documentation to DBCC SHRINKDATABASE, Microsoft is warning to run the command because it's i/o expensive.

However, in the documentation to DBCC SHRINKFILE, there is no such warning.

Now when we use simple recovery and basically have only one database file, is it better to run DBCC SHRINKFILE or DBCC SHRINKDATABASE?

askolotl
  • 255
  • 1
  • 3
  • 10

2 Answers2

3

A database can (and is) composed of multiple files. So shrinking the database would shrink all the files it's composed of, whereas shrinking a file is more granular (as Tibor pointed out). Therefore shrinking a database will always be at least as heavy or heavier of an operation than shrinking just a specific file of the database.

That being said, it's generally recommended against to shrink either because they're both 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.

J.D.
  • 40,776
  • 12
  • 62
  • 141
2

They both do the same thing in the end. But SHRINKFILE is better since it gives you better control. You decide which file to shrink and to what size you want to shrink that file.

Tibor Karaszi
  • 18,269
  • 2
  • 17
  • 30