| From: | Keyerror Smart <smartkeyerror(at)gmail(dot)com> |
|---|---|
| To: | assam258(at)gmail(dot)com |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] Consider window functions when reordering GROUP BY items |
| Date: | 2026-11-24 01:10:10 |
| Message-ID: | CAD=-kXZ8eXSiK+RSquX7HhPwxRYv5unnHg=VYZkVmQ_fdnDbxA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Henson,
> Thanks for v6. I read it again in planning order: where a sorted
> path is kept, how eager aggregation below the join uses it, which
> GROUP BY orders become candidates, which orders the parallel paths
> are sorted in, and what turning the GUC off does. Please correct
> me if I got any of it wrong.
Thanks for the walkthrough. That matches what the patches do, for
each of the four functions and for the GUC turned off.
> I don't think they are dead code. I turned both into Asserts on a
> cassert build, and each fails on one of the attached queries, while
> v6 as posted runs them fine:
> ...
> So I'd keep them as runtime checks.
Thanks for the queries. I ran guards-repro.sql on v7 with a NOTICE
at each guard. The first query reaches the guard in
group_keys_reorder_by_pathkeys() and the second the one in
adjust_group_pathkeys_to_input(), and both run without error. So
both guards stay as they are.
> How about updating it along these lines?
>
> Controls if the query planner will produce a plan which will
> provide GROUP BY keys sorted in the order of keys of a child
> node of the plan, such as an index scan, in either sort
> direction, or in the order required by window functions.
Done, using your wording. I split it between the two patches, so
that each patch documents what it adds: 0001 adds "in either sort
direction", and 0002 adds "or in the order required by window
functions".
Attached is v7. Apart from the docs, it is v6 rebased onto the
current master (f03a0f87963), with no code changes. Regression tests
pass with 0001 alone and with both patches.
Regards,
Zhenglong
| Attachment | Content-Type | Size |
|---|---|---|
| v7-0001-Ignore-sort-direction-when-matching-GROUP-BY-keys.patch | application/octet-stream | 50.2 KB |
| v7-0002-Consider-window-functions-when-reordering-GROUP-B.patch | application/octet-stream | 49.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | shihao zhong | 2026-11-24 01:22:53 | Re: Fix two race conditions in processing interrupts |
| Previous Message | Michael Paquier | 2026-11-24 00:26:02 | Re: reindexdb: Change quoting rule of --schema? |