Re: To-Do item: skip table scan for adding column with provable check constraints - Mailing list pgsql-hackers

From Tom Lane
Subject Re: To-Do item: skip table scan for adding column with provable check constraints
Date
Msg-id 20169.1464130592@sss.pgh.pa.us
Whole thread Raw
In response to Re: To-Do item: skip table scan for adding column with provable check constraints  (ilmari@ilmari.org (Dagfinn Ilmari Mannsåker))
Responses Re: To-Do item: skip table scan for adding column with provable check constraints  (Craig Ringer <craig@2ndquadrant.com>)
List pgsql-hackers
ilmari@ilmari.org (Dagfinn Ilmari Mannsåker) writes:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
>> ... and if the CHECK expression is immutable ...

> Doesn't it have to be already?

AFAIK we don't insist on that currently.  You could imagine useful checks
that are not, for example CHECK(write_timestamp <= now()).

> Otherwise a value accepted at one point in time could suddenly violate
> the constraint later, even though it never changed.

True.  If you use a non-immutable check, it's on your head whether or not
this is a problem.  But the database shouldn't perform optimizations that
just assume it's immutable without checking.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: statistics for shared catalogs not updated when autovacuum is off
Next
From: Alvaro Herrera
Date:
Subject: Re: [sqlsmith] PANIC: failed to add BRIN tuple