Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

In Postgres, each row has a system column xmin which holds the ID of the first transaction to have visibility over that row. Conversely, the xmax system column holds the ID of last trasaction to have visibility over that row.

DROP TABLE IF EXISTS users;
CREATE TABLE users (name varchar(80)) WITH OIDS;
INSERT INTO users VALUES ('root');
SELECT oid, xmin, xmax, name FROM users;
  oid  | xmin | xmax | name 
-------+------+------+------
 16398 |  602 |    0 | root
(1 row)
UPDATE users SET name = 'ssilva' WHERE name = 'root';
SELECT oid, xmin, xmax, name FROM users;
  oid  | xmin | xmax |  name  
-------+------+------+--------
 16398 |  603 |    0 | ssilva
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.