May I know how to release unused space in the database in Azure SQL Managed Instance?

Ramesh Babu 21 Reputation points
2023-08-09T15:36:07.1866667+00:00

May I know how to release unused space from the database in Azure SQL Managed instance ? My Database showing 100GB size but used space is only 1GB, I have tried to shrink the database but unused space is still not released, Can some one help me on this ?

Azure SQL Database
{count} votes

3 answers

Sort by: Most helpful
  1. Alberto Morillo 34,676 Reputation points MVP Volunteer Moderator
    2023-08-09T16:19:55.9833333+00:00

    Instead of using DBCC SHRINKDATABASE please try to use DBCC SHRINKFILE to release allocated space..

    0 comments No comments

  2. way0utwest 81 Reputation points MVP
    2023-08-09T16:50:02.67+00:00

    It would be good to know what you tried. If you clicked Shrink Database in SSMS, this uses SHRINKDATABASe, as Alberto noted.

    You can instead click the files option, shown here:

    2023-08-09 10_48_08-travelqueries.sql - ARISTOTLE_SQL2022.way0utwest_dev (ARISTOTLE_Steve (53))_ - M

    Once you've done that, you can fill out the dialog, as per your specs.

    2023-08-09 10_48_21-Shrink File - AdventofCode

    If you want to use DBCC SHRINKFILE as a code option, connect to your MI and you can see examples here: https://learn.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql?view=sql-server-ver16&source=recommendations#examples

    0 comments No comments

  3. Javier Villegas 905 Reputation points MVP
    2023-08-09T16:59:03.4133333+00:00

    Hello,

    you can shrink the data and log file in MI same as on SQL Server but note that IO depends on file size. as big is the data file more IOPS/Throughput will be available so if you reduce the size from 100 GB to 1 or 2 GB you will notice performance impact

    see "File IO characteristics in General Purpose tier" under below link

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.