Re: using index to speedup add not null constraints to a table - Mailing list pgsql-hackers

From jian he
Subject Re: using index to speedup add not null constraints to a table
Date
Msg-id CACJufxGr=t0N1C87ZgKD4pEQ42mFjS+jEVW=s=D_Mu8i0dnzLA@mail.gmail.com
Whole thread
In response to Re: using index to speedup add not null constraints to a table  (Álvaro Herrera <alvherre@kurilemu.de>)
List pgsql-hackers
On Tue, Apr 7, 2026 at 6:02 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
>
> Hello,
>
> I think you may have not looked at my review at
> https://postgr.es/m/202601131715.cheonohttbyj@alvherre.pgsql
> because as far as I can tell, this new version has essentially the same
> structure as before that review.
>

Hi.

I guess the point I haven't addressed yet is:

> However, if we do this, then I think computing notnull_attrs is
> pointless.  So we should only change the order: do this new check first,
> and if we find that any new not-null column is on a generated column,
> then we compute both notnull_virtual_attrs and notnull_attrs.  No?
>

The attached patch implements this reordering,
first do index_check_notnull then compute both notnull_virtual_attrs
and notnull_attrs.



--
jian
https://www.enterprisedb.com/

Attachment

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: updates for handling optional argument in system functions
Next
From: "David G. Johnston"
Date:
Subject: Re: updates for handling optional argument in system functions