Re: using index to speedup add not null constraints to a table

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: using index to speedup add not null constraints to a table
Date: 2026-04-08 01:45:50
Message-ID: CACJufxGr=t0N1C87ZgKD4pEQ42mFjS+jEVW=s=D_Mu8i0dnzLA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Apr 7, 2026 at 6:02 PM Álvaro Herrera <alvherre(at)kurilemu(dot)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 Content-Type Size
v14-0001-using-indexscan-to-speedup-add-not-null-constraints.patch text/x-patch 20.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David G. Johnston 2026-04-08 01:46:17 Re: updates for handling optional argument in system functions
Previous Message Chao Li 2026-04-08 01:33:56 Re: updates for handling optional argument in system functions