Re: Postgres does not use indexes with OR-conditions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Vlad Arkhipov <arhipov(at)dc(dot)baikal(dot)ru>, David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Postgres does not use indexes with OR-conditions
Date: 2014-11-07 15:11:48
Message-ID: 3340.1415373108@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Kevin Grittner <kgrittn(at)ymail(dot)com> writes:
> On the other hand, why not simply write it as?:

> select *
> from commons.financial_documents fd
> where (fd.creation_time, fd.financial_document_id)
> < ('2011-11-07 10:39:07.285022+08', 100)
> order by fd.creation_time desc
> limit 200

That's the way to do it, not only because it's simpler and clearer,
but because the planner will recognize the relevance of the
condition to an index on creation_time, financial_document_id ...

regards, tom lane

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message David G Johnston 2014-11-07 16:50:26 Re: Postgres does not use indexes with OR-conditions
Previous Message Kevin Grittner 2014-11-07 14:17:31 Re: Postgres does not use indexes with OR-conditions