pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kevin Grittner <kgrittn@ymail.com>
Cc: Andrew Dunstan <andrew@dunslane.net>
Cc: Vlad Arkhipov <arhipov@dc.baikal.ru>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: pgsql-performance <pgsql-performance@postgresql.org>
Subject: Re: Postgres does not use indexes with OR-conditions
Date: Fri, 07 Nov 2014 10:11:48 -0500
Message-ID: <3340.1415373108@sss.pgh.pa.us> (raw)
In-Reply-To: <1415369851.48766.YahooMailNeo@web122305.mail.ne1.yahoo.com>
References: <545C479B.7010104@dc.baikal.ru>
	<CAApHDvr0X+eYy-bZJh-ch3Kr62BJkk=ZWACyndMKJsUBYWjQpg@mail.gmail.com>
	<545C5352.4050309@dc.baikal.ru>
	<545CCF54.1010205@dunslane.net>
	<1415369851.48766.YahooMailNeo@web122305.mail.ne1.yahoo.com>
List-Unsubscribe:  <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>

Kevin Grittner <kgrittn@ymail.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


-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance



view thread (7+ messages)  latest in thread

Message-ID: <3340.1415373108@sss.pgh.pa.us>
Permalink:  ../3340.1415373108@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3340.1415373108@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tgl@sss.pgh.pa.us, kgrittn@ymail.com, andrew@dunslane.net, arhipov@dc.baikal.ru, dgrowleyml@gmail.com
  Subject: Re: Postgres does not use indexes with OR-conditions
  In-Reply-To: <3340.1415373108@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox