ReTrim for MS-SQL production volume

Adrian Nicolae 1 Reputation point
2022-04-03T17:29:35.58+00:00

Hi,

I have a few SQL servers with all the volumes assigned from a SAN network over FC. I need to run Optimize-Volume -Retrim for all the volumes hosting the sql databases in order to unmap the unused blocks from the SAN storage. Is it safe to run the command while the SQL process is up and running or do you need to shutdown the SQL first ?

I'm not planning to run a full defrag, just a retrim. In my mind there shouldn't be any issue running Retrim with the SQL server online because it's not moving any file or block used by sql, it's just sending scsi unmap requests to the backend storage. However, I couldn't find a definitive answer in the official documentation so maybe someone can clear this up for me ?

Thank you.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,684 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,360 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,351 Reputation points
    2022-04-07T07:47:26.18+00:00

    Hi @Adrian Nicolae

    You can safely run this command on your MS-SQL production volume.

    TRIM is not a command that forces the SSD to immediately erase data. The TRIM command simply notifies the SSD which Logical Block Addresses (LBAs) are no longer needed. The SSD takes those addresses and updates its own internal map in order to mark those locations as invalid.

    SCSI UNMAP is the full equivalent of TRIM, but for SCSI disks. UNMAP is a SCSI command that a host can issue to a storage array to free Logical Block Addresses (LBAs) that no longer need to be allocated.

    Windows 2012, 2012 R2, and 2016 natively support the capability to reclaim space is enabled by default.

    Hope this answers your question :)
    Thank you.

    --
    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments