Re: feature idea: use index when checking for NULLs before SET NOT NULL

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 13:21:06
Message-ID: 11131101590757378@mail.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

> Sergei, a few questions:
>
> - Just to be clear, your recipe does not require any indexes, right? Because the constraint check table scan is inherently concurrent?

Right. "alter table validate constraint" can not use indexes, but does not block concurrent read/write queries. Other queries in this scenario can not use indexes too, but should be fast.

> - Was this new behavior mentioned in the release nose?

Yes, small note in documentation and small note in release notes https://www.postgresql.org/docs/12/release-12.html this one:

> Allow ALTER TABLE ... SET NOT NULL to avoid unnecessary table scans (Sergei Kornilov)
> This can be optimized when the table's column constraints can be recognized as disallowing nulls.

> - Do you know if there are any blog posts etc. discussing this? (I'm definitely going to write one!!)

I do not know. Personally, I mentioned this feature in only a few Russian-speaking communities. And right now I wrote answer in dba.SO.

regards, Sergei

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2020-05-29 13:22:14 Re: password_encryption default
Previous Message Stephen Frost 2020-05-29 13:18:27 Re: password_encryption default