From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: David Rowley <drowley@postgresql.org>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Add better handling of redundant IS [NOT] NULL quals
Date: Tue, 23 Jan 2024 20:15:38 +0100
Message-ID: <202401231915.uwk6zrqbdvsu@alvherre.pgsql> (raw)
In-Reply-To: <E1rS92d-002gbO-EJ@gemulon.postgresql.org>
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)
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 using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: alvherre@alvh.no-ip.org, drowley@postgresql.org, pgsql-hackers@lists.postgresql.org
Subject: Re: pgsql: Add better handling of redundant IS [NOT] NULL quals
In-Reply-To: <202401231915.uwk6zrqbdvsu@alvherre.pgsql>
* 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