pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pilum.70@uni-muenster.de
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #10171: Specific prepared statement cannot use bitmapOr index scan since 9.2
Date: Tue, 29 Apr 2014 10:49:27 -0400
Message-ID: <17573.1398782967@sss.pgh.pa.us> (raw)
In-Reply-To: <20140429074155.2644.29021@wrigleys.postgresql.org>
References: <20140429074155.2644.29021@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

pilum.70@uni-muenster.de writes:
> The following query uses bitmap or index scan in 9.1, but only Nested Loop
> in 9.2 and 9.3:

Interesting.  The plan actually gets stupider when it has values for the
parameters, if those values chance to be NULL.

The reason seems to be that after substituting the parameters and
constant-folding, we've got this join condition:

(t1.id2 = ''::text AND t2.id2 = ''::text) OR NULL::boolean

and the code in orclause.c is unable to realize that it can extract the
sub-AND elements as restriction clauses for t1 and t2.  But it'd be
all right to ignore the constant-null OR arm, since that can't possibly
succeed.

Another way of looking at this is that we should be smart enough to throw
away the constant-null OR arm altogether at top level of WHERE, since at
top level we don't particularly care whether the OR produces FALSE or NULL
if all its other inputs are FALSE.  That would probably be a more general
fix.

I'll see what I can do about this.  Thanks for the report!

			regards, tom lane


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



view thread (2+ messages)

Message-ID: <17573.1398782967@sss.pgh.pa.us>
Permalink:  ../17573.1398782967@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/17573.1398782967@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, pilum.70@uni-muenster.de
  Subject: Re: BUG #10171: Specific prepared statement cannot use bitmapOr index scan since 9.2
  In-Reply-To: <17573.1398782967@sss.pgh.pa.us>
  References: <20140429074155.2644.29021@wrigleys.postgresql.org> <17573.1398782967@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