Shrink the data file on Azure SQL MI

azure-sql-managed-instanceshrink

I have a 600GB DB with 400GB free space in the data file on Azure SQL MI.
I am planning to shrink it and save the storage, but it's a critical DB with the user sessions.

There are two plans:

Plan A: Shrink the data file down to 210GB at one time.

Plan B: Shrink 5GB every time and execute one by one.

Do you have any thoughts? What's the benefit of plan B?

Best Answer

Mainly the only difference I can think of is Plan A will cause continuous database contention, where Plan B will be shorter periods of contention at a time, but could take longer to complete overall. If you have a very busy database, Plan B may minimize performance issues, but if your database is set to grow in increments greater than the rate you can shrink by 5 GB, then it may be a fruitless attempt.

Additionally, you shouldn't normally be shrinking your database as it's generally a wasteful heavier operation. Instead you should determine what caused the large growth, if it was normal, and if your database growth settings are appropriately configured.