Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx> 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;

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux