ALTER TABLE VALIDATE CONSTRAINT w/o lock

Поиск
Список
Период
Сортировка
От Torsten Förtsch
Тема ALTER TABLE VALIDATE CONSTRAINT w/o lock
Дата
Msg-id 5254184E.3040408@gmx.net
обсуждение исходный текст
Список pgsql-general
Hi,

I want to add a new column named sell_time to a table which already has
a boolean field named is_sold. Then I want to create a new check constraint:

ALTER TABLE ...
CHECK(is_sold AND sell_time IS NOT NULL OR
      NOT is_sold AND sell_time IS NULL)
NOT VALID;

The constraint is added as NOT VALID for 2 reasons. 1) it is not valid
at that point and 2) I cannot afford the lock required to validate the it.

According to the docs subsequent operations on the table must pass the
constraint.

Now I can slowly populate the new column. After a while I'll reach a
point where the constraint is valid for all rows.

How can I tell that the database without the re-validation?

Alternatively, is there a way to make the constraint validation really
fast (a few seconds at most for 50.000.000 rows)? (this is 9.3)

Thanks,
Torsten


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

Предыдущее
От: David Johnston
Дата:
Сообщение: Re: Urgent Help Required
Следующее
От: shailesh singh
Дата:
Сообщение: Re: Urgent Help Required