Re: Subqueries and the optimizer

Поиск
Список
Период
Сортировка
От Stephan Szabo
Тема Re: Subqueries and the optimizer
Дата
Msg-id 20030520141545.G75450-100000@megazone23.bigpanda.com
обсуждение исходный текст
Ответ на Re: Subqueries and the optimizer  ("Dmitri Bichko" <dbichko@genpathpharma.com>)
Список 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 по дате отправления:

Предыдущее
От: Rod Taylor
Дата:
Сообщение: Re: sequence caches
Следующее
От: Mike Mascari
Дата:
Сообщение: Re: Subqueries and the optimizer