From 1d45ec058dafb03b8fd6cfd4a87387970a6e06ca Mon Sep 17 00:00:00 2001 From: James Coleman Date: Fri, 24 Sep 2021 09:59:27 -0400 Subject: [PATCH v1] Document atthasmissing default avoids verification table scan When PG11 added the ability for ALTER TABLE ADD COLUMN to set a constant default value without rewriting the table the doc changes did not note how the new feature interplayed with ADD COLUMN DEFAULT NOT NULL. Previously such a new column required a verification table scan to ensure no values were null. That scan happens under an exclusive lock on the table, so it can have a meaningful impact on database "accessible uptime". Here we document that the new mechanism also precludes that scan. --- doc/src/sgml/ddl.sgml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml index e0ffb02..d3f2b27 100644 --- a/doc/src/sgml/ddl.sgml +++ b/doc/src/sgml/ddl.sgml @@ -1360,6 +1360,8 @@ ALTER TABLE products ADD COLUMN description text; is executed. Instead, the default value will be returned the next time the row is accessed, and applied when the table is rewritten, making the ALTER TABLE very fast even on large tables. + Additionally adding a column with a constant default value avoids a + a table scan to verify no NULL values are present. -- 2.10.1