extracting multiple results from a set of tuples

Поиск
Список
Период
Сортировка
От merlino
Тема extracting multiple results from a set of tuples
Дата
Msg-id 1192188408.140955.68950@y27g2000pre.googlegroups.com
обсуждение исходный текст
Список 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


В списке pgsql-general по дате отправления:

Предыдущее
От: Robert Treat
Дата:
Сообщение: Re: SLEEP in posgresql
Следующее
От: Joao Miguel Ferreira
Дата:
Сообщение: replicating to a stopped server