Search Postgresql Archives

extracting multiple results from a set of tuples

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@xxxxxxxxxxxxxx so that your
       message can get through to the mailing list cleanly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux