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 17827.1464126595@sss.pgh.pa.us
Whole thread Raw
In response to Re: To-Do item: skip table scan for adding column with provable check constraints  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: To-Do item: skip table scan for adding column with provable check constraints  (ilmari@ilmari.org (Dagfinn Ilmari Mannsåker))
List pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes:
> Right.  If there were a DEFAULT on the new column that would of course
> be different, and you can also do thinks like CHECK (a != b) here.
> However, if the CHECK constraint does not reference any column other
> than the newly-added one, and if the new column will have the same
> value for every row either because there is no default or because the
> default is a constant,

... and if the CHECK expression is immutable ...

> then we can test the CHECK constraint just once
> against the value that all new rows will have instead of testing it
> once per row.

I'm not entirely sure that this case occurs often enough to be worth the
trouble.  Although your formulation suggests that we could just execute
the expression once, rather than attempting to prove it true which is
what I think Jeff had in mind.  That would expand the scope of usefulness
considerably.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Allow COPY to use parameters
Next
From: Kevin Grittner
Date:
Subject: Re: Re: [COMMITTERS] pgsql: Avoid extra locks in GetSnapshotData if old_snapshot_threshold <