From: Stefano Dal Pra <s.dalpra@gmail.com>
To: pgsql-sql@postgresql.org
Cc: pgsql-performance@postgresql.org
Subject: two queryes in a single tablescan
Date: Wed, 17 Oct 2007 14:30:52 +0200
Message-ID: <290a5abc0710170530v215cb2b0q4fa000ad43096a28@mail.gmail.com> (raw)
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
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: s.dalpra@gmail.com, pgsql-performance@postgresql.org
Subject: Re: two queryes in a single tablescan
In-Reply-To: <290a5abc0710170530v215cb2b0q4fa000ad43096a28@mail.gmail.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