Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, 8 Sep 2021, 06:59 hubert depesz lubaczewski, <depesz@xxxxxxxxxx> 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.


Regards,
--
Alexander Kukushkin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux