From: | Sergei Kornilov <sk(at)zsrv(dot)org> |
---|---|
To: | John Bachir <j(at)jjb(dot)cc>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: feature idea: use index when checking for NULLs before SET NOT NULL |
Date: | 2020-05-29 06:56:38 |
Message-ID: | 1034971590734717@mail.yandex.ru |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | 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 not null 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
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2020-05-29 07:04:38 | Re: OpenSSL 3.0.0 compatibility |
Previous Message | Michael Paquier | 2020-05-29 06:48:40 | Re: segmentation fault using currtid and partitioned tables |