Re: Optimizing maximum/minimum queries (yet again)

Поиск
Список
Период
Сортировка
От Mark Kirkwood
Тема Re: Optimizing maximum/minimum queries (yet again)
Дата
Msg-id 42574993.20101@paradise.net.nz
обсуждение исходный текст
Ответ на Optimizing maximum/minimum queries (yet again)  (Tom Lane)
Список pgsql-hackers
Looks great! I had been slowly thinking along similar lines via the 
equivalence:

SELECT min(x) FROM tab WHERE...

SELECT min(x) FROM (SELECT x FROM tab WHERE ... ORDER BY x LIMIT 1) AS t


However, it looks like your approach is more flexible than this :-)

best wishes

Mark


Tom Lane wrote:
> 
> I realized today that this may not be as hard as I thought.
> Specifically, I'm imagining that we could convert
> 
>     SELECT min(x), max(y) FROM tab WHERE ...
> 
> into sub-selects in a one-row outer query:
> 
>     SELECT (SELECT x FROM tab WHERE ... ORDER BY x LIMIT 1),
>            (SELECT y FROM tab WHERE ... ORDER BY y DESC LIMIT 1);
> 
> Breaking it down like that means we can consider each aggregate
> independently, which definitely simplifies matters.  


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

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Optimizing maximum/minimum queries (yet again)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Optimizing maximum/minimum queries (yet again)