pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: hubert depesz lubaczewski <depesz@depesz.com>
To: Alexander Kukushkin <cyberdemn@gmail.com>
Cc: pgsql-general mailing list <pgsql-general@postgresql.org>
Subject: Re: Is there any technical reason why "alter table .. set not null" can't use index?
Date: Wed, 8 Sep 2021 07:14:53 +0200
Message-ID: <20210908051453.GB20274@depesz.com> (raw)
In-Reply-To: <CAFh8B==Jqo2L1u53oeSp5o6c-d1Wx0_qejBQ6DjZ5agZ-3750g@mail.gmail.com>
References: <20210908045919.GA29476@depesz.com>
	<CAFh8B==Jqo2L1u53oeSp5o6c-d1Wx0_qejBQ6DjZ5agZ-3750g@mail.gmail.com>

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@depesz.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






view thread (5+ messages)  latest in thread

Message-ID: <20210908051453.GB20274@depesz.com>
Permalink:  ../20210908051453.GB20274@depesz.com/
Also on:    postgresql.org/message-id/20210908051453.GB20274@depesz.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: depesz@depesz.com, cyberdemn@gmail.com
  Subject: Re: Is there any technical reason why "alter table .. set not null" can't use index?
  In-Reply-To: <20210908051453.GB20274@depesz.com>
  References: <20210908045919.GA29476@depesz.com> <CAFh8B==Jqo2L1u53oeSp5o6c-d1Wx0_qejBQ6DjZ5agZ-3750g@mail.gmail.com> <20210908051453.GB20274@depesz.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox