Обсуждение: Adding columns dynamically to a table

Поиск
Список
Период
Сортировка

Adding columns dynamically to a table

От
"Avinash Lakshman"
Дата:
Hi

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 ? Basically the number of columns differ per key. Are there any techniques that are available with Postgres for such operations ?

Thanks
A

Re: Adding columns dynamically to a table

От
Tom Lane
Дата:
"Avinash Lakshman" <avinash.lakshman@gmail.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