Re: using index to speedup add not null constraints to a table
jian he <jian.universality@gmail.com>
From: jian he <jian.universality@gmail.com>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-05-14T09:16:14Z
Lists: pgsql-hackers
Attachments
- v6-0001-using-indexscan-to-speedup-add-not-null-constrain.patch (application/x-patch) patch v6-0001
On Mon, Apr 28, 2025 at 4:40 PM Álvaro Herrera <alvherre@kurilemu.de> wrote: > > On 2025-Apr-28, jian he wrote: > > > for tests, just found out i can imitate > > src/test/modules/test_misc/t/001_constraint_validation.pl, > > > > So I created a file: > > src/test/modules/test_misc/t/008_indexscan_validate_notnull.pl > > for TAP tests. > > Seems reasonable, didn't look at it in detail. I think you don't have > any tests where you try to set multiple columns as NOT NULL in a single > ALTER TABLE command; I think this is worth having. Something like > > CREATE TABLE foo (col1 int, col2 int, col3 int); > ... create indexes on col1 and col2 ... > alter table foo set col1 not null, > set col3 not null, > add constraint bla not null b; > and stuff like that. > newly added tests covered that. now the test coverage is quite good, IMHO. also rebased to address test failure.