public inbox for [email protected]
help / color / mirror / Atom feedFrom: Ankit Kumar Pandey <[email protected]>
To: David Rowley <[email protected]>
Cc: pghackers <[email protected]>
Cc: Vik Fearing <[email protected]>
Subject: Re: Todo: Teach planner to evaluate multiple windows in the optimal order
Date: Sun, 8 Jan 2023 11:59:27 +0530
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAApHDvqD0B21J2Z44G+_KEf8AmqHPjhuwbX4b6NB2eyP2CZo=w@mail.gmail.com>
References: <[email protected]>
<CAApHDvp=r1LnEKCmWCYaruMPL-jP4j_sdc8yeFYwaDT1ac5GsQ@mail.gmail.com>
<[email protected]>
<CAApHDvq=g2=ny59f1bvwRVvupsgPHK-KjLPBsSL25fVuGZ4idQ@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
<CAApHDvruS-3gG_KYXPb_=Um_TfUXi+G4o7VyBVbChTjThXF2yA@mail.gmail.com>
<[email protected]>
<[email protected]>
<CAApHDvpEYcQ7d-c6Lje26gLi4dXOM3qQ9nrTe1Z241tT8nBiCg@mail.gmail.com>
<[email protected]>
<[email protected]>
<CAApHDvqD0B21J2Z44G+_KEf8AmqHPjhuwbX4b6NB2eyP2CZo=w@mail.gmail.com>
On 08/01/23 04:06, David Rowley wrote:
> On Sun, 8 Jan 2023 at 05:45, Ankit Kumar Pandey <[email protected]> wrote:
>> Attached patch with test cases.
> I can look at this in a bit more detail if you find a way to fix the
> case you mentioned earlier. i.e, push the sort down to the deepest
> WindowAgg that has pathkeys contained in the query's ORDER BY
> pathkeys.
> EXPLAIN (COSTS OFF)
> SELECT empno,
> depname,
> min(salary) OVER (PARTITION BY depname ORDER BY empno) depminsalary,
> sum(salary) OVER (PARTITION BY depname) depsalary
> FROM empsalary
> ORDER BY depname, empno, enroll_date;
> QUERY PLAN
> -----------------------------------------------
> Incremental Sort
> Sort Key: depname, empno, enroll_date
> Presorted Key: depname, empno
> -> WindowAgg
> -> WindowAgg
> -> Sort
> Sort Key: depname, empno
> -> Seq Scan on empsalary
> (8 rows)
>
> You'll also need to pay attention to how the has_runcondition is set.
> If you start pushing before looking at all the WindowClauses then you
> won't know if some later WindowClause has a runCondition.
Yes, this should be the main culprit.
> Adding an additional backwards foreach loop should allow you to do all the
> required prechecks and find the index of the WindowClause which you
> should start pushing from.
This should do the trick. Thanks for headup, I will update the patch
with suggested
changes and required fixes.
Regards,
Ankit
view thread (60+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Todo: Teach planner to evaluate multiple windows in the optimal order
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox