"database is full" with TMPDIR pointing at a 5TB partition: 3̶2̶-̶b̶i̶t̶ ̶b̶u̶g̶?

The main bit from the speed up is probably the sorting effect from vacuum which reduces the random page selection cost. On ‘metal’ disks the random page selection cost can be really bad