Re: Add columns - Mailing list pgsql-general

From Tom Lane
Subject Re: Add columns
Date
Msg-id 18364.1136312141@sss.pgh.pa.us
Whole thread Raw
In response to Add columns  (P G <pgress5@yahoo.com>)
List pgsql-general
P G <pgress5@yahoo.com> writes:
> I see that one can add a new column to an existing
> table.  The documentation was not clear on how
> efficient this operation would be.
> Does PostgreSQL make a copy of the entire table when
> adding a new column?  Or does it simply use extra
> space in the data blocks to add the new column?

If the new column has no default expression (ie, default null) then
adding a column doesn't touch the table at all, only some catalog
entries.

Inserting data into the column is expensive, of course, since you
have to update every row in the table to put it there.  This is
not different from any other UPDATE operation.

            regards, tom lane

pgsql-general by date:

Previous
From: Andreas Kretschmer
Date:
Subject: Re: generic way to retrieve array as rowset
Next
From: "Chander Ganesan"
Date:
Subject: Re: Need Licensing Information for bundling POSTGRESQL With Softwares