| From: | Sebastien Arod <sebastien(dot)arod(at)gmail(dot)com> |
|---|---|
| To: | Michael Lewis <mlewis(at)entrata(dot)com> |
| Cc: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Is postgres able to share sorts required by common partition window functions? |
| Date: | 2020-07-06 20:28:48 |
| Message-ID: | CADd42iFGCSuscEeW1yLULLMxq_sD8aVxn=gy+Z7xABC0YeXEDQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)entrata(dot)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;
>
>>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Rowley | 2020-07-06 20:49:18 | Re: Apply LIMIT when computation is logically irrelevant |
| Previous Message | Michael Lewis | 2020-07-06 19:55:00 | Re: Is postgres able to share sorts required by common partition window functions? |