pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: acamargo@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15408: Postgresql bad planning with multicolumn gist and search with empty results
Date: Thu, 27 Sep 2018 10:03:31 -0400
Message-ID: <1818.1538057011@sss.pgh.pa.us> (raw)
In-Reply-To: <15408-18cb801b3a5b21a5@postgresql.org>
References: <15408-18cb801b3a5b21a5@postgresql.org>

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> As seen in the explain results, when I search for non-existent values of n2,
> the plan changes on Index condition used, giving poor plans. None of this
> plan differences appear if the index is btree. It seems something gist
> related, and I need to use gist due to PostGIS functions.

I don't have time to dig in the code right now, but my recollection is
that btcostestimate() has fairly detailed modeling of the behavior of
queries that constrain only some columns of an index, eg it understands
that "col1 = constant" is much cheaper to scan than "col2 = constant".
On the other hand, gistcostestimate() has no such modeling and assumes
that a constraint on a lower-order column is worth the same as one on
the first column.

This is partially due to lack of effort put into that function, but I seem
to recall being told that GIST was not as sensitive to column ordering
as btree, too.  Your results indicate otherwise :-(

Depending on what other queries you use, maybe an adequate workaround
would be to switch the two columns of the index.

			regards, tom lane




view thread (4+ messages)  latest in thread

Message-ID: <1818.1538057011@sss.pgh.pa.us>
Permalink:  ../1818.1538057011@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1818.1538057011@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, acamargo@gmail.com
  Subject: Re: BUG #15408: Postgresql bad planning with multicolumn gist and search with empty results
  In-Reply-To: <1818.1538057011@sss.pgh.pa.us>
  References: <15408-18cb801b3a5b21a5@postgresql.org> <1818.1538057011@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