From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | Dmitri Bichko <dbichko(at)genpathpharma(dot)com> |
Cc: | <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Subqueries and the optimizer |
Date: | 2003-05-20 21:19:09 |
Message-ID: | 20030520141545.G75450-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, 20 May 2003, Dmitri Bichko wrote:
> I wish it were as easy as a join - the query is much simplified for the
> purpose of the example, in reality the subselect is more complicated and
> includes a GROUP BY (which, at least as far as I know, makes subqueries
> the only way of doing this).
But you may be able to do it as a subselect in FROM rather than a
subselect in IN (err, right).
For example, barring possible NULL related wierdness:
select * from a where col in (select count(*) from b group by col2);
can probably be done as something like:
select a.* from a, (select distinct count(*) as count from b group by
col2) as b where a.col=b.count;
which in some cases for 7.3 and earlier will be better.
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2003-05-20 23:25:52 | Re: Subqueries and the optimizer |
Previous Message | Rod Taylor | 2003-05-20 21:14:31 | Re: sequence caches |