Re: Is postgres able to share sorts required by common partition window functions?

Поиск
Список
Период
Сортировка
От Sebastien Arod
Тема Re: Is postgres able to share sorts required by common partition window functions?
Дата
Msg-id CADd42iFGCSuscEeW1yLULLMxq_sD8aVxn=gy+Z7xABC0YeXEDQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Is postgres able to share sorts required by common partition window functions?  (Michael Lewis <mlewis@entrata.com>)
Список pgsql-general
Hi Michael,

I simplified the real query before posting it here and I now realize that I oversimplified things.

Unfortunately the real query cannot be re-written with a group by.

Some of the window functions are more complex with order by clause using complex expressions involving multiple columns.

The following example would be more realistic:

select distinct
  c1,
  first_value(c2) OVER (PARTITION BY c1 order by c2, c4) AS c2,
  first_value(c3) OVER (PARTITION BY c1 order by coalesce(c4, '000'), c3) AS c3
from  
  t;



On Mon, Jul 6, 2020 at 9:55 PM Michael Lewis <mlewis@entrata.com> wrote:
Does this give the same result and do the optimization you want?

select
  c1,
  min(c2) AS c2,
  min(c3) AS c3,
  min(c4) AS c4
from  
  t
group by
  c1;

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

Предыдущее
От: Michael Lewis
Дата:
Сообщение: Re: Is postgres able to share sorts required by common partition window functions?
Следующее
От: David Rowley
Дата:
Сообщение: Re: Apply LIMIT when computation is logically irrelevant