Search Postgresql Archives

ALTER TABLE VALIDATE CONSTRAINT w/o lock

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

 



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


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[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 Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux