Re: Is there any technical reason why "alter table .. set not null" can't use index?

From: hubert depesz lubaczewski <depesz(at)depesz(dot)com>
To: Alexander Kukushkin <cyberdemn(at)gmail(dot)com>
Cc: pgsql-general mailing list <pgsql-general(at)postgresql(dot)org>
Subject: Re: Is there any technical reason why "alter table .. set not null" can't use index?
Date: 2021-09-08 05:14:53
Message-ID: 20210908051453.GB20274@depesz.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Sep 08, 2021 at 07:09:31AM +0200, Alexander Kukushkin wrote:
> Hi,
>
> On Wed, 8 Sep 2021, 06:59 hubert depesz lubaczewski, <depesz(at)depesz(dot)com>
> wrote:
>
> > Hi,
> > we needed recently to add not null constraint on some fields, and it
> > struck me that it took long.
> > Obviously - pg has to check the data. But it seems that it can't use
> > index.
> >
>
> It can't use the index, but can use an already existing CHECK CONSTRAINT,
> that could be created as NOT VALID and validated without holding heavy
> locks. After adding not null you can drop the constraint.

Thanks. Forgot about these.

Best regards,

depesz

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jehan-Guillaume de Rorthais 2021-09-08 06:39:03 Re: prevent WAL replication to fill filesystem
Previous Message Alexander Kukushkin 2021-09-08 05:09:31 Re: Is there any technical reason why "alter table .. set not null" can't use index?