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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: David Rowley <drowley(at)postgresql(dot)org>, 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:38:54
Message-ID: 4071562.1706038734@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> writes:
> On 2024-Jan-23, David Rowley wrote:
>> 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.

IIRC, we realized that that concern was bogus. Removal of such
constraints would cause pg_attribute.attnotnull to change, leading
to a relcache invalidation on the table, forcing replan. If anyone
tried to get rid of attnotnull or make it incompletely reliable,
then we'd have problems; but AFAIK that's not being contemplated.

regards, tom lane

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2024-01-23 19:40:49 pgsql: Support shared libraries on Android (using make)
Previous Message Alvaro Herrera 2024-01-23 19:15:38 Re: pgsql: Add better handling of redundant IS [NOT] NULL quals

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-01-23 19:42:54 Re: Build versionless .so for Android
Previous Message Tristan Partin 2024-01-23 19:20:15 Remove pthread_is_threaded_np() checks in postmaster