pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: dmigowski@ikoffice.de
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #7629: Suboptimal query plan when index search is possible and an additional search operator is given.
Date: Tue, 30 Oct 2012 10:29:56 -0400
Message-ID: <10946.1351607396@sss.pgh.pa.us> (raw)
In-Reply-To: <E1TTAJt-0004X5-Gw@wrigleys.postgresql.org>
References: <E1TTAJt-0004X5-Gw@wrigleys.postgresql.org>

dmigowski@ikoffice.de writes:
> However, when I also want to order by id:
>    order by prep_natural_sort(d.number) ASC, 
>             d.id ASC  
> it does a sequential scan.

Sure.  That index doesn't satisfy this sort order.  (It could have
gotten chosen anyway, if the partial-index predicate were selective
enough, but evidently it isn't.)

> This is a bit stupid, also because the relevant data could be fetched very
> fast by the first order-by expression, and then the results could be ordered
> again, which is then much faster than doing a full sequential scan on the
> data.

That's an unsupported assertion, which we'd have to write a great deal
of code before we could even test.  There are a lot of more useful
places to spend hacking time, with greater assurance of the work not
being wasted.

			regards, tom lane




view thread (2+ messages)

Message-ID: <10946.1351607396@sss.pgh.pa.us>
Permalink:  ../10946.1351607396@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/10946.1351607396@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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dmigowski@ikoffice.de
  Subject: Re: BUG #7629: Suboptimal query plan when index search is possible and an additional search operator is given.
  In-Reply-To: <10946.1351607396@sss.pgh.pa.us>
  References: <E1TTAJt-0004X5-Gw@wrigleys.postgresql.org> <10946.1351607396@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