Sql-server – Why can’t I defragment the SQL 2008 .mdf file

defragsql server

I am defragmenting a badly (95%) fragmented drive upon which large (35 gig) SQL Server 2008 .mdf files live. After defragmenting and viewing the exception report, I see that the production .mdf file that I'm most interested in could not be defragmented. I initially figured it was because MSSQL had an exclusive lock on the file, so I detached it and tried again. No luck – this particular .mdf file could not be defragmented. What am I missing? Most online references suggest that I should be able to file defrag an .mdf

A note: yes, I'm talking about file defragmentation, not index defrag, which is already being done routinely, and which I'll re-run after this.

Thanks! What am I missing?

Best Answer

What am I missing?

Nothing, it should normally defagment it. Not that deframgmenting it makes sense given that - well - th e content are fully random access anyway. More important to have a NTFS file system with 64k nodes (standard is 4) being properly aligned (in cae it is a RAID drive) to avod split IO.

But it should defragement it.