FW: [GENEAL] dynamically changing table - Mailing list pgsql-general

From Michael Black
Subject FW: [GENEAL] dynamically changing table
Date
Msg-id BLU144-W2517ACE5BE7CFF41A91F7CFA8D0@phx.gbl
Whole thread Raw
In response to [GENEAL] dynamically changing table  (A B <gentosaker@gmail.com>)
List pgsql-general

 

From: michaelblack75052@hotmail.com
To: gentosaker@gmail.com
Subject: RE: [GENERAL] [GENEAL] dynamically changing table
Date: Mon, 30 Mar 2009 16:05:52 +0000

.ExternalClass .EC_hmmessage P {padding:0px;} .ExternalClass body.EC_hmmessage {font-size:10pt;font-family:Verdana;} The simplest way is to plan for the maximum number of columns that will be required (say 14 - 2 weeks of data assuming that is daily reporting numbers in the columns.  You could have only a single data column and in the first record insert the number of columns that need to be processed, and build the data in the method to load an array to simulate a "record" object for that number.  Then process cor the lenghth of the array.
 
Or you could use the Drop table and Create table instead of Delete data and Alter Table.  Also by varying the number of columns you have programming considerations in addition.  The the input and process meths will need to check the meta data to determine how many columns it is dealing with.
 
Those are just to options that come to mind.
 
Michael
 
> Date: Mon, 30 Mar 2009 17:39:19 +0200
> Subject: [GENERAL] [GENEAL] dynamically changing table
> From: gentosaker@gmail.com
> To: pgsql-general@postgresql.org
>
> Hi,
> In the next project I'm going to have a number of colums in my tables,
> but I don't know how many, they change. They all use integers as
> datatype though.. One day, I get 2 new columns, a week later I loose
> one column, and so on in a random pattern.
>
> I will most likely have a few million rows of data so I just wonder if
> there are any problems with running
> alter table x add column .....
> or
> alter table x drop column .....
>
> Adding a column, will it place data "far away" on the disc so that
> select * from x where id=y will result in not quite optimal
> performance since it has to fetch columns from a lot of different
> places?
> Will deleting a column result in a lot of empty space that will anoy
> me later on?
>
> Are there any other clever solutions of this problem?
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: David Fetter
Date:
Subject: Re: [GENEAL] dynamically changing table
Next
From: Adrian Klaver
Date:
Subject: Re: running two clusters on one machine