Re: Limit + group + join

Поиск
Список
Период
Сортировка
От Tobias Brox
Тема Re: Limit + group + join
Дата
Msg-id 20050826020635.GM10328@tobias.lan
обсуждение исходный текст
Ответ на Re: Limit + group + join  ("Jeffrey W. Baker" <jwbaker@acm.org>)
Список pgsql-performance
[Jeffrey W. Baker - Thu at 06:56:59PM -0700]
> > explain select c.id from c join b on c_id=c.id  group by c.id order by c.id
> > desc limit 5;
>
> Where's b in this join clause?

"join b on c_id=c.id"

It just a funny way of writing:

select c.id from c,b where c_id=c.id  group by c.id order by c.id desc limit 5;

> It looks like a cartesian product to me.

No.  The query will return exactly the same as the simplest query:

  select c.id from c order by c.id  desc limit 5;

As said, this is a gross oversimplification of the production envorinment.
In the production environment, I really need to use both join, group and
limit.  I tested a bit with subqueries, it was not a good solution
(selecting really a lot of rows and aggregates from many of the tables).

The next idea is to hack it up by manually finding out where the "limit"
will cut, and place a restriction in the where-part of the query.

--
Notice of Confidentiality: This information may be confidential, and
blah-blah-blah - so please keep your eyes closed.  Please delete and destroy
this email.  Failure to comply will cause my lawyer to yawn.

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

Предыдущее
От: "Jeffrey W. Baker"
Дата:
Сообщение: Re: Limit + group + join
Следующее
От: "Jeffrey W. Baker"
Дата:
Сообщение: Re: Limit + group + join