Hi folks, We have this Tip box under the "Adding a Column" header here:
- https://www.postgresql.org/docs/current/ddl-alter.html#DDL-ALTER-ADDING-A-COLUMN That says: > From PostgreSQL 11, adding a column with a constant default value no longer > means that each row of the table needs to be updated when the ALTER TABLE > statement 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. I'm just seeking clarification if this advice is true **even for** new columns declared with NOT NULL? Historically, I've had to add new fields on existing big tables with a NULL to avoid downtime, but it may be different when a DEFAULT is provided? I have used perf to profile the call-chain for adding a NOT NULL column with a default versus just an ordinary NULL with a default, and they are fairly similar. However, I see these functions being called in both cases: - ATRewriteTables find_composite_type_dependencies systable_beginscan index_rescan btrescan And the names raised my eyebrow... I don't have a deep understanding of the internals here, so it would be great if someone could clarify this for me. Thanks, Marcelo.