Skip site navigation (1) Skip section navigation (2)

Re: Adding columns dynamically to a table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Avinash Lakshman" <avinash(dot)lakshman(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Adding columns dynamically to a table
Date: 2007-08-11 04:16:28
Message-ID: 22104.1186805788@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
"Avinash Lakshman" <avinash(dot)lakshman(at)gmail(dot)com> writes:
> I am new to PostGres and I am evaluating it for our purposes. The biggest
> requirement I have is that I need the ability to constantly add columns
> dynamically to a table. How is the efficiency of such an operation ?

Adding a column is nearly free (just a few system-catalog updates) if
you are willing to have it filled with NULLs initially.

Populating it with values could be pretty expensive --- whole-table
UPDATE is not really PG's strongest point.

Also, how many columns does "constantly" add up to?  There's a hard
limit of something like 1600 columns per table, and in practice you
don't want to have more than a couple hundred.  If you think you need
enormously wide tables, perhaps it's time to rethink your schema.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Josh TolleyDate: 2007-08-11 05:04:28
Subject: Re: Free designable front end for PostgreSQL
Previous:From: Tom LaneDate: 2007-08-11 04:10:00
Subject: Re: pg_dump/pg_dumpall

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group