Re: pg17 issues with not-null contraints

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Alexander Lakhin <exclusion(at)gmail(dot)com>, Dmitry Koval <d(dot)koval(at)postgrespro(dot)ru>
Subject: Re: pg17 issues with not-null contraints
Date: 2024-05-06 16:41:22
Message-ID: ZjkIMposlYMFkbMQ@pryzbyj2023
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, May 06, 2024 at 06:34:16PM +0200, Alvaro Herrera wrote:
> On 2024-May-06, Justin Pryzby wrote:
>
> > > (Do you really want the partition to be
> > > created without the primary key already there?)
> >
> > Why not ? The PK will be added when I attach it one moment later.
> >
> > CREATE TABLE part (LIKE parent);
> > ALTER TABLE parent ATTACH PARTITION part ...
>
> Well, if you load data in the meantime, you'll spend time during `ALTER
> TABLE parent` for the index to be created. (On the other hand, you may
> want to first create the table, then load data, then create the
> indexes.)

To be clear, I'm referring to the case of CREATE+ATTACH to avoid a
strong lock while creating a partition in advance of loading data. See:
20220718143304(dot)GC18011(at)telsasoft(dot)com
f170b572d2b4cc232c5b6d391b4ecf3e368594b7
898e5e3290a72d288923260143930fb32036c00c

> This would also solve your complaint, because then the table would have
> the not-null constraint in all cases.

I agree that it would solve my complaint, but at this time I've no
further opinion.

--
Justin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2024-05-06 17:04:13 Re: backend stuck in DataFileExtend
Previous Message Alvaro Herrera 2024-05-06 16:34:16 Re: pg17 issues with not-null contraints