two queryes in a single tablescan

Поиск
Список
Период
Сортировка
От Stefano Dal Pra
Тема two queryes in a single tablescan
Дата
Msg-id 290a5abc0710170530v215cb2b0q4fa000ad43096a28@mail.gmail.com
обсуждение исходный текст
Ответы Re: two queryes in a single tablescan  (Heikki Linnakangas <heikki@enterprisedb.com>)
Re: two queryes in a single tablescan  ("Steinar H. Gunderson" <sgunderson@bigfoot.com>)
Re: two queryes in a single tablescan  (李彦 Ian Li <liyan82@gmail.com>)
Re: [SQL] two queryes in a single tablescan  (Markus Schaber <schabi@logix-tt.com>)
Список pgsql-performance
Hi everybody,

suppose you have a large table tab and two (or more) queryes like this:

SELECT count(*),A FROM tab WHERE C GROUP BY A;
SELECT count(*),B FROM tab WHERE C GROUP BY B;

is there any way to get both results in a single query,
eventually through stored procedure?
The retrieved [count(*),A] ; [count(*),B)] data couldnt fit
on a single table, of course.

The main goal would be to get multiple results while scanning the
table[s] once only
thus getting results in a faster  way.

This seems to me quite a common situation but i have no clue whether a neat
solution can be implemented through stored procedure.

Any hint?

Thank you

Stefano

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

Предыдущее
От: Stéphane Schildknecht
Дата:
Сообщение: Re: Vacuum goes worse
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: two queryes in a single tablescan