Sql-server – Shrink database after drop table

drop-tableshrinksql server

I had a table with 70+ million records in a SQL Server database, I dropped that table (a one-time thing) to free up space on the disk, but it looks like the size didn't change much. I do see that I could shrink the db to a minimum.

Is that the way to do it?

The last time I did a shrink using SQL Server Management Studio, it took a few hours to complete. Is there a faster way?

enter image description here

Best Answer

Dropping a table will free up the space within the database, but will not release the space back to Windows. That requires shrinking the database file. However we don't want the database file full. We want lots of free space so that as we load more data we don't have to grow the data file frequently. This causes fragmentation of the data file on the physical disks.

As for making shrinking faster, no there's no way to make it faster. Shrinking the database requires reading and rewriting most of the data within the database so that all the white space can be released from the database file back to the OS. All this IO takes time, and causes a lot of fragmentation problems.