pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: KÖPFERL Robert <robert.koepferl@sonorys.at>
To: pgsql-sql@postgresql.org
Subject: btree and is null in a static expression
Date: Mon, 18 Apr 2005 09:23:25 +0200
Message-ID: <ED4E30DD9C43D5118DFB00508BBBA76EB166B4@neptun.sonorys.at> (raw)

Hi,

I've written a function but I don't understand the the plan, the planner
makes.
If variables are replaced, the function looks like that:

select a,b,c from "Tbl1" where (a='454') or ('454' is null);


a has got an btree-Index.

explain verbose tells me that Postgres wants to do a SEQSCAN
If the last subexpression is omitted like
select a,b,c from "Tbl1" where (a='454') or false;

The planner wants expecedly utilize an index.

How comes that, while it is obvious that the last subexpression evaluates to
false and thus can be omitted or can even be statically evaluated

I read about btree-Indexes and that they can't be used when null comes into
play. But there?


Thanks



Message-ID: <ED4E30DD9C43D5118DFB00508BBBA76EB166B4@neptun.sonorys.at>
Permalink:  ../ED4E30DD9C43D5118DFB00508BBBA76EB166B4@neptun.sonorys.at/
Also on:    postgresql.org/message-id/ED4E30DD9C43D5118DFB00508BBBA76EB166B4@neptun.sonorys.at

 · 

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-sql@postgresql.org
  Cc: robert.koepferl@sonorys.at
  Subject: Re: btree and is null in a static expression
  In-Reply-To: <ED4E30DD9C43D5118DFB00508BBBA76EB166B4@neptun.sonorys.at>
  References: <ED4E30DD9C43D5118DFB00508BBBA76EB166B4@neptun.sonorys.at>

* 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