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

Поиск
Список
Период
Сортировка
От Alexander Kukushkin
Тема Re: Is there any technical reason why "alter table .. set not null" can't use index?
Дата
Msg-id CAFh8B==Jqo2L1u53oeSp5o6c-d1Wx0_qejBQ6DjZ5agZ-3750g@mail.gmail.com
обсуждение исходный текст
Ответ на Is there any technical reason why "alter table .. set not null" can't use index?  (hubert depesz lubaczewski <depesz@depesz.com>)
Ответы Re: Is there any technical reason why "alter table .. set not null" can't use index?  (hubert depesz lubaczewski <depesz@depesz.com>)
Список pgsql-general
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.


Regards,
--
Alexander Kukushkin

В списке pgsql-general по дате отправления:

Предыдущее
От: hubert depesz lubaczewski
Дата:
Сообщение: Is there any technical reason why "alter table .. set not null" can't use index?
Следующее
От: hubert depesz lubaczewski
Дата:
Сообщение: Re: Is there any technical reason why "alter table .. set not null" can't use index?