Difference between "add column" and "add column" with default - Mailing list pgsql-general

From Guido Neitzer
Subject Difference between "add column" and "add column" with default
Date
Msg-id A447D03A-AE21-435F-9E88-EB3EBDC31EC5@pharmaline.de
Whole thread Raw
Responses Re: Difference between "add column" and "add column" with default  (Martijn van Oosterhout <kleptog@svana.org>)
Re: Difference between "add column" and "add column" with default  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi.

What is the technical difference between adding a column to a table
and then apply a "set value = ..." to all columns and adding a column
with a default value = ...?

I have seen that the first duplicates all rows, I had to vacuum and
reindex the whole table. Okay so far, I have expected this. But this
wasn't necessary with the second option, nevertheless, fetching some
rows showed, that the value of the new column was my default value.

So, I'm curious: what happens (not) here?

Thx for the explanation.

cug

Attachment

pgsql-general by date:

Previous
From: Dragan Matic
Date:
Subject: vacuum full taking much longer than dump + restore?
Next
From: Martijn van Oosterhout
Date:
Subject: Re: vacuum full taking much longer than dump + restore?