How to swap postgresql rows physical locations?
That being said, I came up with the idea of sorting table's rows in place, swapping their physical location in incremental steps, to gradually improve table's rows physical organization. Is this possible/safe with plain SQL? (ex: issuing updates based on the ctid column)


You can't swap CTIDs in plain sql. You'll get an error.

ERROR:  cannot assign to system column "ctid"


Further, you can't modify a row at all without totally rewriting the row. It's how MVCC works.