Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iF35l-0000HQ-V0 for pgsql-general@arkaria.postgresql.org; Mon, 30 Sep 2019 21:20:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iF35k-0002rO-IG for pgsql-general@arkaria.postgresql.org; Mon, 30 Sep 2019 21:20:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iF35k-0002rC-85 for pgsql-general@lists.postgresql.org; Mon, 30 Sep 2019 21:20:24 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iF35h-0003uw-86 for pgsql-general@postgresql.org; Mon, 30 Sep 2019 21:20:23 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x8ULJAUs027689; Mon, 30 Sep 2019 17:19:10 -0400 From: Tom Lane To: Joe Horsnell cc: "pgsql-general@postgresql.org" Subject: Re: Behaviour adding a column with and without a default (prior to PG11) In-reply-to: <88D6C2B1-1346-45A5-AC08-37C52D75DD83@bambooloans.com> References: <88D6C2B1-1346-45A5-AC08-37C52D75DD83@bambooloans.com> Comments: In-reply-to Joe Horsnell message dated "Mon, 30 Sep 2019 20:02:47 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <27687.1569878350.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Sep 2019 17:19:10 -0400 Message-ID: <27688.1569878350@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Joe Horsnell writes: > The documentation (https://www.postgresql.org/docs/10/ddl-alter.html) cl= early states that adding a column with a default requires updating all the= rows in the table, to store the new column value (this is prior to PG11, = obviously). > Obviously the desired effect of adding the column default without rewrit= ing all the rows in the table can be achieved by adding the nullable colum= n first with no default, then changing the default, but out of curiosity; = was there a specific technical reason for the behaviour described above, o= r was it a conscious design choice? We read the SQL spec as requiring this behavior. regards, tom lane