Re: creating CHECK constraints as NOT VALID

Kevin Grittner <kevin.grittner@wicourts.gov>

From: "Kevin Grittner" <Kevin.Grittner@wicourts.gov>
To: "Alvaro Herrera" <alvherre@alvh.no-ip.org>, "Pg Hackers" <pgsql-hackers@postgresql.org>
Date: 2011-05-31T16:35:01Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix pg_get_constraintdef to cope with NOT VALID constraints

Alvaro Herrera <alvherre@alvh.no-ip.org> wrote:
 
> This patch allows you to initially declare a CHECK constraint as
> NOT VALID, similar to what we already allow for foreign keys. 
> That is, you create the constraint without scanning the table and
< after it is committed, it is enforced for new rows; later, all
> rows are checked by running ALTER TABLE VALIDATE CONSTRAINT, which
> doesn't need AccessExclusive thus allowing for better concurrency.
 
I think it's a valuable feature, not just in terms of timing and
concurrency, but in terms of someone starting with less-than-perfect
data who wants to prevent further degradation while cleaning up the
existing problems.  This feature is present in other databases I've
used.
 
-Kevin