Re: pgsql: Add better handling of redundant IS [NOT] NULL quals

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: David Rowley <drowley(at)postgresql(dot)org>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Add better handling of redundant IS [NOT] NULL quals
Date: 2024-01-23 19:15:38
Message-ID: 202401231915.uwk6zrqbdvsu@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 2024-Jan-23, David Rowley wrote:

> Add better handling of redundant IS [NOT] NULL quals
>
> Until now PostgreSQL has not been very smart about optimizing away IS
> NOT NULL base quals on columns defined as NOT NULL.

Hmm, what happens if a NOT NULL constraint is dropped and you have such
a plan in plancache? As I recall, lack of a mechanism to invalidate
such plans was the main reason for Postgres not to have this. One of
the motivations for adding catalogued NOT NULL constraints was precisely
to have an OID that you could use to cause plancache to invalidate such
a plan. Does this new code add something like that?

Admittedly I didn't read the threads or the patch, just skimmed for some
clues, so I may have failed to notice it. But in the tests you added I
don't see any ALTER TABLE DROP CONSTRAINT.

(Similarly, allowing GROUP BY to ignore columns not in the GROUP BY,
when a UNIQUE constraint exists and all columns are NOT NULL; currently
we allow that for PRIMARY KEY, but if you have the NOT NULL constraint
OIDs to cue the plan invalidation would let that case to be implemented
as well.)

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Por suerte hoy explotó el califont porque si no me habría muerto
de aburrido" (Papelucho)

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-01-23 19:38:54 Re: pgsql: Add better handling of redundant IS [NOT] NULL quals
Previous Message Peter Eisentraut 2024-01-23 19:08:57 pgsql: meson: Map host_system android to linux

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2024-01-23 19:18:18 Re: Shared detoast Datum proposal
Previous Message Heikki Linnakangas 2024-01-23 19:07:08 Re: Refactoring backend fork+exec code