Shink file VS Resize

  • Michael_O

    Ten Centuries

    Points: 1244

    I have a database of about 325GB with free space ~120GB and we're having drive alerts go off so i need to free some space.
    I know that i could possibly shrink this DB which is a bad idea as it causes fragmentation and will end up just growing the database back in no time. Another approach that i have used in the past that has worked faster than shrinking, even on large database, is resizing the database file using the GUI, files tab in database properties.
    What i need help with at this time is understanding the difference between shrink and resize, and the pros and cons of resizing. Can't seem to find anything online so thought my gurus here might have an idea.
    Thanks in advance!

  • Gail Shaw

    SSC Guru

    Points: 1004424

    Michael_O - Thursday, September 7, 2017 9:57 AM

    What i need help with at this time is understanding the difference between shrink and resize

    None.
    The GUI calls DBCC ShrinkFile or DBCC ShrinkDatabase, depending whether you selected the option to shrink the file or the entire DB.

    Can't seem to find anything online

    Because resize isn't a thing.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Chris Harshman

    SSC-Forever

    Points: 41610

    Depending on where that 120 GB is in your data file, you could potentially be able to use the TRUNCATEONLY functionality of DBCC SHRINKFILE
    https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql
    This makes it only remove unused pages at the end of the file without reorganizing any other pages.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply