Re: BUG #1252: Optimization of SELECT for NOT NULL case

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruno Wolff III <bruno(at)wolff(dot)to>
Cc: Alexander Kirpa <postgres(at)bilteks(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1252: Optimization of SELECT for NOT NULL case
Date: 2004-09-15 18:07:10
Message-ID: 5946.1095271630@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Bruno Wolff III <bruno(at)wolff(dot)to> writes:
> On Tue, Sep 14, 2004 at 00:57:07 +0100,
>> CREATE TABLE x (id int4 NOT NULL);
>> SELECT count(*) from x WHERE x IS NULL;
>> Optimizator should rewrite "x IS NULL" to simple "false"

> Based on responses to other optimization requests I have seen, I think the
> answer to this one is going to be that it isn't worth paying the cost
> for every query to check for this case, since no one is going to write
> a query like this except by mistake.

There's been some speculation about making the optimizer aware of table
constraints in general (eg, CHECK constraints) but I tend to agree that
doing this only for NOT NULL isn't very exciting.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alexander Kirpa 2004-09-15 20:29:43 Re: BUG #1252: Optimization of SELECT for NOT NULL case
Previous Message Jacek Rembisz 2004-09-15 17:49:47 Re: character and text comparison