Re: Add columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: P G <pgress5(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Add columns
Date: 2006-01-03 18:15:41
Message-ID: 18364.1136312141@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

P G <pgress5(at)yahoo(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albert Vernon Smith 2006-01-03 18:36:47 Re: insert serial numbers
Previous Message Andreas Kretschmer 2006-01-03 18:12:09 Re: generic way to retrieve array as rowset