Re: Fast AT ADD COLUMN with DEFAULTs - Mailing list pgsql-hackers

From Serge Rielau
Subject Re: Fast AT ADD COLUMN with DEFAULTs
Date
Msg-id 3DCBC086-9E66-4AD9-B9B5-8F5A5E03C62C@rielau.com
Whole thread Raw
In response to Re: Fast AT ADD COLUMN with DEFAULTs  (Vitaly Burovoy <vitaly.burovoy@gmail.com>)
Responses Re: Fast AT ADD COLUMN with DEFAULTs  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> On Oct 6, 2016, at 5:25 AM, Vitaly Burovoy <vitaly.burovoy@gmail.com> wrote:
>
> On 10/6/16, Simon Riggs <simon@2ndquadrant.com> wrote:
>> On 6 October 2016 at 04:43, Serge Rielau <serge@rielau.com> wrote:
>>>>> Or should I compose some sort of a design document?
>>
>> Having read this thread, I'm a little unclear as to what you're
>> writing now, though there's definitely good ideas here.
>>
>> I think it would be beneficial to write up a single coherent
>> description of this, including behaviour and a small sketch of
>> implementation, just so everyone knows what this is. No design doc,
>> but a summary.
>
> At the moment I think it can also be a good idea to post the current
> patch as a Proposal or a WIP to get initial feedback.
I can do that -  Accompanied by a posting sized overview.

>
> Yes, it works for stable "now()" but does not work for volatile
> functions like "random()", "uuid_generate_v4()" or default for serial
> columns. The only possible way I can see is to check an expression has
> only "T_Const"s, static and stable functions. In such case the
> expression can be evaluated and the result be saved as a value for
> absented attributes of a tuple. In the other case save NULL there and
> rewrite the table.
Agreed. I think DEFAULT as-is does the job nicely function wise.
One can always decompose the ADD COLUMN into two steps within the same transaction
if the initial column value for pre-existing rows does not match the default for new or updated rows.
AT Just needs a performance boost for large tables where that’s reasonably possible.

>> Which makes me think we should call this missing_value or absent_value
>> so its clear that it is not a "default" it is the value we use for
>> rows that do not have any value stored for them.
>
> It is definitely a default for a user, it is not a regular default internally.
> I'm not a native speaker, "absent_value" can be mixed up with a NULL.
> As for me the best phrase is "pre-add-column-default", but it is
> impossible to use it as a column name. :-(
> It is still an open question.
I like Tom’s “creation default”. Another one could be “initial default”.
But that, too, can be misread.

Cheers
Serge Rielau
Salesforce.com


pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Hash Indexes
Next
From: Peter Geoghegan
Date:
Subject: Re: memory leak in e94568ecc10 (pre-reading in external sort)