order of evaluation of search arguments - Mailing list pgsql-general

From Kiriakos Georgiou
Subject order of evaluation of search arguments
Date
Msg-id 7A4F291C-3B32-4DDC-BB3E-82A374972B61@olympiakos.com
Whole thread Raw
Responses Re: order of evaluation of search arguments
List pgsql-general
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?

begin;

select *
from queue q
where
   q.status = 'unprocessed'
   and pg_try_advisory_xact_lock(q.qid, q.tableoid::int) = true
limit 2 -- specify batch size here
for update;

-- now process the queue items

Kiriakos



pgsql-general by date:

Previous
From: Ondrej Ivanič
Date:
Subject: Re: Rules of Thumb for Autovaccum
Next
From: "Rajan, Pavithra"
Date:
Subject: Re: Dump functions alone