Deletions

There's something a little different that happens during DELETE instead. Close out any open sessions you might have with unfinished transactions seen before. Now, let's start another transaction to delete a row:

postgres=# BEGIN; 
BEGIN 
postgres=# DELETE FROM t WHERE s=1; 
DELETE 1 
postgres=# SELECT * from t; 
 s | i  
---+--- 
(0 rows) 

Once again, if you look at this table from another session, because it's not been committed yet, the row deleted here will still be there, just with an xmax value set:

$ psql -c "SELECT *,xmin,xmax FROM t;" 
 s |  i  |  xmin  |  xmax   
---+-----+--------+-------- 
 1 | 101 | 158213 | 158214

Only in the first session has the row been deleted. This brings us to a second form of visibility that needs to be considered: ...

Get PostgreSQL 10 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.