| From: | Ankit Kumar Pandey <itsankitkp(at)gmail(dot)com> |
|---|---|
| To: | David Rowley <dgrowleyml(at)gmail(dot)com> |
| Cc: | pghackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Vik Fearing <vik(at)postgresfriends(dot)org> |
| Subject: | Re: Todo: Teach planner to evaluate multiple windows in the optimal order |
| Date: | 2023-01-08 10:21:35 |
| Message-ID: | 12f6ef19-e06e-8ea9-ad98-3fd92afb7f0b@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi David,
Please find attached patch with addressed issues mentioned before.
Things resolved:
1. Correct position of window function from where order by push down can
happen
is determined, this fixes issue mentioned in case #1.
> While writing test cases, I found that optimization do not happen for
> case #1
>
> (which is prime candidate for such operation) like
>
> 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
2. Point #2 as in above discussions
> a) looks like the best plan to me. What's the point of pushing the
> sort below the WindowAgg in this case? The point of this optimisation
> is to reduce the number of sorts not to push them as deep into the
> plan as possible. We should only be pushing them down when it can
> reduce the number of sorts. There's no reduction in the number of
> sorts in the above plan.
Works as mentioned.
All test cases (newly added and existing ones) are green.
--
Regards,
Ankit Kumar Pandey
| Attachment | Content-Type | Size |
|---|---|---|
| better_windowclause_sorting_dgr-v3.patch | text/x-patch | 13.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dmitry Dolgov | 2023-01-08 10:56:01 | Re: [RFC] Add jit deform_counter |
| Previous Message | Ankit Kumar Pandey | 2023-01-08 06:29:27 | Re: Todo: Teach planner to evaluate multiple windows in the optimal order |