Kiriakos Georgiou <kg.postgresql@xxxxxxxxxxxxxx> writes: > As I understand it the order the of evaluation of search arguments is up to the optimizer. I've tested the following query, that is supposed to take advantage of advisory locks to skip over rows that are locked by other consumers running the exact same query and it seems to work fine. It seems to me the optimizer should always prefer to scan by status. What say you? "When it breaks, you get to keep both pieces." Was your testing even capable of noticing the problem if the query locked more rows than you wanted? Less dangerous coding practices might involve putting the lock function in an outer query, while using an OFFSET 0 in the sub-query as an optimization fence. regards, tom lane -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general