Implementation of Rollback in PostgreSQL
Apart from some side tasks like releasing locks, deleting files and similar, the main activity is to set the two bits that correspond to the transaction in the commit log (in pg_xact) to &ldquo;aborted&rdquo; and sync the file to disk.

A rollback does not touch the table at all, and it should always be fast.
The newly created row version simply remain in the table (to be cleaned up later by autovacuum), they just become invisible because the transaction that created them has been aborted. Similar with deleted data: the marker that the row was deleted by the transaction simply becomes invalid.