From: a <372660931@qq.com>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: Ways to deal with large amount of columns;
Date: Fri, 31 Aug 2018 08:47:36 +0800
Message-ID: <tencent_2EB8658617C930525A0A9C8E@qq.com> (raw)
In-Reply-To: <CAKFQuwZWTUDVCTKcTBwCapPZQ9gp20eLDtiPGz=V-x07Y5xWfw@mail.gmail.com>
References: <tencent_74B211A80785C27C5C3C58D8@qq.com>
<CAKFQuwZWTUDVCTKcTBwCapPZQ9gp20eLDtiPGz=V-x07Y5xWfw@mail.gmail.com>
Thank you very much. Creating a function seems to be a good idea :)
------------------ Original message ------------------
From: "David G. Johnston";
Sendtime: Thursday, Aug 30, 2018 8:31 PM
To: "a"<372660931@qq.com>;
Cc: "pgsql-general";
Subject: Re: Ways to deal with large amount of columns;
On Thursday, August 30, 2018, a <372660931@qq.com> wrote:
Hi all:
I need to make a table contains projected monthly cashflow for multiple agents (10,000 around).
Therefore, the column number would be 1000+.
I would need to perform simple aggregate function such as count, sum or average on each cashflow projected.
So if there is anyway of doing this? Will there be anything like define a macro in C that I can manipulate multiple columns by simple word that representing them.
Better to design a data model that doesn't have so many columns. Otherwise generating dynamic SQL via the for,at function and loops and such is your best bet. Can be down in pl/pgsql or in your preferred programming language. Psql variables can maybe be useful too.
David J.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: 372660931@qq.com, david.g.johnston@gmail.com
Subject: Re: Ways to deal with large amount of columns;
In-Reply-To: <tencent_2EB8658617C930525A0A9C8E@qq.com>
References: <tencent_74B211A80785C27C5C3C58D8@qq.com> <CAKFQuwZWTUDVCTKcTBwCapPZQ9gp20eLDtiPGz=V-x07Y5xWfw@mail.gmail.com> <tencent_2EB8658617C930525A0A9C8E@qq.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox