Alter table says rewrite is required for default values on 11.

From: PG Doc comments form <noreply(at)postgresql(dot)org>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Cc: mr-russ(at)smith2001(dot)net
Subject: Alter table says rewrite is required for default values on 11.
Date: 2018-10-09 03:40:27
Message-ID: 153905642709.4092.5299467551020533340@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/10/static/ddl-alter.html
Description:

https://www.postgresql.org/account/comments/new/11/ddl-alter.html/
indicates that the table needs a rewrite when a column with a default value
is added, my understanding of the 11 changes meant that is not true any
longer. The blog post below supports that unless the feature was disabled
in future.

https://blog.dbi-services.com/postgresql-11-instant-add-column-with-a-non-null-default-value/

The specific bit of "Tip" text is;
---
Adding a column with a default requires updating each row of the table (to
store the new column value). However, if no default is specified, PostgreSQL
is able to avoid the physical update. So if you intend to fill the column
with mostly nondefault values, it's best to add the column with no default,
insert the correct values using UPDATE, and then add any desired default as
described below.

Browse pgsql-docs by date

  From Date Subject
Next Message fn ln 2018-10-10 13:14:23 v11: RETURN syntax for procedure
Previous Message Jonathan S. Katz 2018-10-09 01:38:24 Re: Proposed HTML Documentation Styles