Andreas Joseph Krogh <andr...@visena.com> writes:
> I have this "dequeue" query which is working:
>  
> select qe.entity_id, qe.queue_id, qe.sequence_id, qe.tx_id , 
> qe.payload_string 
> fromorigo_queue_entry qe WHERE qe.queue_id = 2 AND pg_try_advisory_xact_lock(
> sequence_id) LIMIT 1 FOR UPDATE ; 
> I'm not sure is this is guaranteed to lock in ASC-order on column 
> sequence_id, 
> is it?

No.  You could possibly do SELECT...ORDER BY...FOR UPDATE in a
subquery and do the pg_try_advisory_xact_lock call in the outer query.

It might take some fooling around to get a plan that doesn't lock
more rows than necessary; EXPLAIN is your friend.

                        regards, tom lane


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to