hanselman[.]com/blog/the-real-and-complete-story-does-windows-defragment-your-ssd
After reading a How-To article I was looking for a blog post I bookmarked quite a while ago -- a couple days later I found it. While I believe I posted about it [probably long ago], I thought it might not hurt to re-post it as a reminder. The blog makes two points: SSDs do get defragged, but you need System Restore for that drive turned on.
This is an older blog post [from 2014] that I *think* is probably still accurate -- I spent some time Googling & could not find anything related, i.e., if Win10 or 11 are the same or different. Checking logs with Event Viewer IMHO indicates the blog is still correct.
Storage Optimizer will defrag an SSD once a month if volume snapshots are enabled. This is by design and necessary due to slow volsnap copy on write performance on fragmented SSD volumes. It’s also somewhat of a misconception that fragmentation is not a problem on SSDs. If an SSD gets too fragmented you can hit maximum file fragmentation (when the metadata can’t represent any more file fragments) which will result in errors when you try to write/extend a file. Furthermore, more file fragments means more metadata to process while reading/writing a file, which can lead to slower performance.As far as Retrim is concerned, this command should run on the schedule specified in the dfrgui UI. Retrim is necessary because of the way TRIM is processed in the file systems. Due to the varying performance of hardware responding to TRIM, TRIM is processed asynchronously by the file system. When a file is deleted or space is otherwise freed, the file system queues the trim request to be processed. To limit the peek resource usage this queue may only grow to a maximum number of trim requests. If the queue is of max size, incoming TRIM requests may be dropped. This is okay because we will periodically come through and do a Retrim with Storage Optimizer. The Retrim is done at a granularity that should avoid hitting the maximum TRIM request queue size where TRIMs are dropped.