I understand that shrinking the data files is a bad idea in SQL Server due to index fragmentation.
I want to ensure that I completely understand before arguing my point.
I know that when
dbcc shrinkfile (unless with
truncateonly) is run, the pages from the back are moved to free spaces in an earlier position.
Does this function get the very last page in the data file and place it in the first available space?
In other words, if we have this situation:
[ Page 1 ] [ Page 2 ] [ empty1 ] [ empty2 ] [ Page 3 ] [ Page 4 ] [ empty3 ] [ empty4 ] [ Page 5 ]
...after executing a
dbcc shrinkfile would
[ Page 5 ] be moved to
[ empty1 ] because that is the first available slot? and so on...
In the end it eventually would look like this:
[ Page 1 ] [ Page 2 ] [ Page 5 ] [ Page 4 ] [ Page 3 ]
Any help would be appreciated.