| 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-07-16 08:55:56 |
| Message-ID: | CACJufxFaNH_LVHi8cd+AkKS4Jx7ihbyBEN9tyCxSW=MZPVTS6A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi.
In get_relation_info, we have:
/*
* If the index is valid, but cannot yet be used, ignore it; but
* mark the plan we are generating as transient. See
* src/backend/access/heap/README.HOT for discussion.
*/
if (index->indcheckxmin &&
!TransactionIdPrecedes(HeapTupleHeaderGetXmin(indexRelation->rd_indextuple->t_data),
TransactionXmin))
{
root->glob->transientPlan = true;
index_close(indexRelation, NoLock);
continue;
}
So I did the same thing in index_check_notnull.
As the reason mentioned in [1], using indexscan to verify not-null can
only apply to the leading column of the index.
So we only need to do one ScanKeyEntryInitialize for indexscan
| Attachment | Content-Type | Size |
|---|---|---|
| v15-0001-using-indexscan-to-speedup-add-not-null-constraints.patch | text/x-patch | 21.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | wenhui qiu | 2026-07-16 09:08:35 | Re: PGLZ Compression Optimization |
| Previous Message | vignesh C | 2026-07-16 08:52:27 | Re: Fix publisher-side sequence permission reporting |