I tested it by visual inspection of advisory locks in pg_locks; once with a
small test table, and once on a larger 'operations' table in our test
environment. It seemed to work, but I hear you, I don't like to depend on the
mood of the optimizer. The drawback of the subquery version is that if
Kiriakos Georgiou 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 a