Alvaro Herrera <alvhe...@alvh.no-ip.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