Aggregation question

From: "Dilip Angal" <dilip_angal(at)yahoo(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: Aggregation question
Date: 2004-02-04 05:27:48
Message-ID: 001b01c3eadf$a0a684e0$6601a8c0@angals
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Hi

I have a situation that I need flexible number columns to model the business requirements. It could go up to 1000 columns and will be a sparse matrix. One option I was considering was to have a table with col1......col1000
Other option I can consider is store all of them as name values in single column as a string

option 1
col1 | col2 |col 3 |........|col56|.....|col77|
10 | 2 | | | 4 | | |
2 | | 4 | | |.... |6 |

option 2

"col1=10,col2=2,col56=4"
"col1=2,col3=4,col77=6"

I will have about 50Million such records in a table.

I need to aggregate the column values for a given day by taking sum of all the rows

"col1=12,col2=2,col3=4,col56=4,col77=6"

Second option looks very elegant but aggregation is hard
Besides, second option may have performance penalty (Especially when you have 50 Million records)

Any one can give any pointers or comments on how to model this an how to aggregate it?

Thanks
Dilip

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-02-04 05:47:13 Re: Transfer database tables to a schema
Previous Message Steve Atkins 2004-02-04 04:46:52 Re: application developers list?? or report engine using postgres?

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2004-02-04 05:39:37 Re: PITR Dead horse?
Previous Message Christopher Kings-Lynne 2004-02-04 04:25:16 Re: Recursive queries?