order of evaluation of search arguments

From: Kiriakos Georgiou <kg(dot)postgresql(at)olympiakos(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: order of evaluation of search arguments
Date: 2012-02-16 02:08:34
Message-ID: 7A4F291C-3B32-4DDC-BB3E-82A374972B61@olympiakos.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tomonari Katsumata 2012-02-16 02:21:29 postgresql90-server package for RHEL5
Previous Message Ondrej Ivanič 2012-02-16 00:25:43 Re: Rules of Thumb for Autovaccum