Re: Removing const-false IS NULL quals and redundant IS NOT NULL quals

From: Richard Guo <guofenglinux(at)gmail(dot)com>
To: Andy Fan <zhihuifan1213(at)163(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, Andrei Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Removing const-false IS NULL quals and redundant IS NOT NULL quals
Date: 2023-12-27 11:58:26
Message-ID: CAMbWs4_SVvKOeOj62Ty4z2jtFdnwN_0nsV6KA2F9arvh5rmyVA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Wed, Dec 27, 2023 at 7:38 PM Andy Fan <zhihuifan1213(at)163(dot)com> wrote:

> I also want to add notnullattnums for the UniqueKey stuff as well, by
> comparing your implementation with mine, I found you didn't consider
> the NOT NULL generated by filter. After apply your patch:
>
> create table a(a int);
> explain (costs off) select * from a where a > 3 and a is null;
> QUERY PLAN
> -------------------------------------
> Seq Scan on a
> Filter: ((a IS NULL) AND (a > 3))
> (2 rows)

The detection of self-inconsistent restrictions already exists in
planner.

# set constraint_exclusion to on;
SET
# explain (costs off) select * from a where a > 3 and a is null;
QUERY PLAN
--------------------------
Result
One-Time Filter: false
(2 rows)

Thanks
Richard

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Guo 2023-12-27 12:15:35 Re: BUG #18260: Unexpected error: "negative bitmapset member not allowed" triggered by multiple JOIN
Previous Message Andy Fan 2023-12-27 11:20:38 Re: Removing const-false IS NULL quals and redundant IS NOT NULL quals

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2023-12-27 12:00:09 Re: Failed assertion in joininfo.c, remove_join_clause_from_rels
Previous Message Andreas Seltenreich 2023-12-27 11:54:22 Failed assertion in joininfo.c, remove_join_clause_from_rels