Re: feature idea: use index when checking for NULLs before SET NOT NULL - Mailing list pgsql-hackers

From Sergei Kornilov
Subject Re: feature idea: use index when checking for NULLs before SET NOT NULL
Date
Msg-id 1034971590734717@mail.yandex.ru
Whole thread Raw
In response to feature idea: use index when checking for NULLs before SET NOT NULL  ("John Bachir" <j@jjb.cc>)
Responses Re: feature idea: use index when checking for NULLs before SET NOT NULL
Re: feature idea: use index when checking for NULLs before SET NOT NULL
List pgsql-hackers
Hello

Correct index lookup is a difficult task. I tried to implement this previously...

But the answer in SO is a bit incomplete for recent postgresql releases. Seqscan is not the only possible way to set
notnull in pg12+. My patch was commited ( https://commitfest.postgresql.org/22/1389/ ) and now it's possible to do this
way:

alter table foos 
     add constraint foos_not_null 
     check (bar1 is not null) not valid; -- short-time exclusive lock

alter table foos validate constraint foos_not_null; -- still seqscan entire table but without exclusive lock

An then another short lock:
alter table foos alter column bar1 set not null;
alter table foos drop constraint foos_not_null;

regards, Sergei



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: segmentation fault using currtid and partitioned tables
Next
From: Daniel Gustafsson
Date:
Subject: Re: OpenSSL 3.0.0 compatibility