I am executing the following queries (id has a unique key):
1) begin; 1) delete from forum where id = 20; 1) insert into forum (id, name) values (20, 'test'); 2) delete from forum where id = 20; 1) commit;
If you do these side by side in interactive psql sessions, you'll see that the process 2) delete from forum where id=20; waits and waits and doesn't start until you commiut process 1). So from the point of view of Process 2, it sees the committed forum table and it has no entries in the forum table with id 20, hence DELETE 0 is its output. So the effective sequence of events is: 1) begin; 1) delete from forum where id = 20; 1) insert into forum (id, name) values (20, 'test'); 1) commit; 2) delete from forum where id = 20; Hope this helps, Stuart.