I've been looking at some lower level storage stuff for postgres and I was curious about when postgres was writing stuff to disk, specifically when working with updates or transactions.
The ctid
represents the physical storage location of the row on disk. Something like (5,8)
could be thought of as page 5 + (offset 8 x row width)
. By looking at this we can know the position of the last written row, which means we'll know if a new row is being written of if the row is being reused.
For example, the last row written to the users table is (5,8).
front_desk_development=# select MAX(ctid) from users;
max
-------