Re: [HACKERS] To-Do item: skip table scan for adding column with provable check constraints

2016-05-25 Thread Jim Nasby
On 5/24/16 9:56 PM, Craig Ringer wrote: On 25 May 2016 at 06:56, Tom Lane mailto:t...@sss.pgh.pa.us>> wrote: ilm...@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes: > Tom Lane mailto:t...@sss.pgh.pa.us>> writes: >> ... and if the CHECK exp

Re: [HACKERS] To-Do item: skip table scan for adding column with provable check constraints

2016-05-24 Thread Craig Ringer
On 25 May 2016 at 06:56, Tom Lane wrote: > ilm...@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes: > > Tom Lane 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

Re: [HACKERS] To-Do item: skip table scan for adding column with provable check constraints

2016-05-24 Thread Tom Lane
ilm...@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) writes: > Tom Lane 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

Re: [HACKERS] To-Do item: skip table scan for adding column with provable check constraints

2016-05-24 Thread Dagfinn Ilmari Mannsåker
Tom Lane writes: > Robert Haas 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 n

Re: [HACKERS] To-Do item: skip table scan for adding column with provable check constraints

2016-05-24 Thread Tom Lane
Robert Haas 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 s

Re: [HACKERS] To-Do item: skip table scan for adding column with provable check constraints

2016-05-24 Thread Robert Haas
On Thu, May 19, 2016 at 7:33 PM, Jeff Janes wrote: > I recently had to run something like: > > alter table pgbench_accounts add locked text check (locked != 'unlocked'); > > And was surprised that it took several minutes to complete as it > scanned the whole table. > > The new column is going to s