From: | merlino <s(dot)dalpra(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | extracting multiple results from a set of tuples |
Date: | 2007-10-12 11:26:48 |
Message-ID: | 1192188408.140955.68950@y27g2000pre.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi all, I am writing a few pg/plsql and have no great experience, so
i'm asking here.
I need to obtain <X1>,<X2>,.. from N queryes like these:
SELECT <X1> FROM tab GROUP BY <Y1>
SELECT <X2> FROM tab GROUP BY <Y2>
SELECT <X3> FROM tab WHERE C3 GROUP BY <Y3> [eventually ORDER BY Z3];
example:
SELECT count(*),name FROM tab GROUP BY name;
SELECT sum(seconds), job FROM tab WHERE status = 1 GROUP BY job;
etc;
Doing this way the table tab would be scanned once per SELECT (tab is
a quite large table).
Since it hurts to me the idea of repeating many queryes on the
identical set of tuples
I would like to write a stored procedure who produceses these results
putting them
into a few "temporary" tables, so i ask you:
is there a way to obtain <X1>, <X2>, <X3> with a single tables scan?
May you point me to an example?
I hope i was clear enough explaining the problem.
Thank you
Stefano
From | Date | Subject | |
---|---|---|---|
Next Message | Nico Sabbi | 2007-10-12 11:29:11 | Re: ORDER BY - problem with NULL values |
Previous Message | Richard Huxton | 2007-10-12 11:04:06 | Re: how to truncate/purge the pg_xlog directory? |