Shrink the data file on Azure SQL MI

All we need is an easy explanation of the problem, so here it is.

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?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

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.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply