btree and is null in a static expression

From: KÖPFERL Robert <robert(dot)koepferl(at)sonorys(dot)at>
To: pgsql-sql(at)postgresql(dot)org
Subject: btree and is null in a static expression
Date: 2005-04-18 07:23:25
Message-ID: ED4E30DD9C43D5118DFB00508BBBA76EB166B4@neptun.sonorys.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message Frank Habermann 2005-04-18 13:31:09 user connection over tcp
Previous Message Dinesh Pandey 2005-04-18 06:31:58 "pltcl" function.