Re: Subqueries and the optimizer - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Subqueries and the optimizer
Date
Msg-id 20030520141545.G75450-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: Subqueries and the optimizer  ("Dmitri Bichko" <dbichko@genpathpharma.com>)
List 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.



pgsql-general by date:

Previous
From: Rod Taylor
Date:
Subject: Re: sequence caches
Next
From: Mike Mascari
Date:
Subject: Re: Subqueries and the optimizer