Csaba Nagy <nagy@xxxxxxxxxxxxxx> writes: > I'm not sure how this operation can work in the presence of other long > running transactions which did not touch the queue table yet, but it > actually does work, I can confirm that. Is it violating MVCC maybe ? Yes :-(. I think you can get away with it if all your transactions that use the queue table run in READ COMMITTED (not serializable) mode, and if they work like BEGIN; LOCK queue_table IN some-suitable-mode; process queue table; COMMIT; Grabbing the lock will ensure that CLUSTER finishes before any snapshot is taken. regards, tom lane