Uh oh!
There was an error while loading. Please reload this page.
Prevent exponential planning time for Window functions - #17563
Conversation
It was added as limited to avoid long benchmark time. However, criterion just runs fewer iterations in such case. Larger benchmark range better shows the problem, while still being real-life scenario.
Before the change, the planning time was exponential with respect to number of columns used in window partitioning clause. This is a stop-gap solution to avoid exponential planning time.
1353a6f to
92e9cb2Comparefindepi
commented
Sep 15, 2025
Will post benchmark results soon |
findepi
commented
Sep 15, 2025
BeforeAfterA |
alamb
commented
Sep 16, 2025
I will review this today |
alamb
commented
Sep 16, 2025
🤖 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
alamb
commented
Sep 16, 2025
🤖: Benchmark completed Details |
alamb
commented
Sep 16, 2025
🤖 |
alamb
commented
Sep 16, 2025
🤖: Benchmark completed Details |
alamb
commented
Sep 18, 2025
I am pretty torn on this PR It clearly solves the planning time problem: (186x speedup!) But it also causes a potential regression by resorting data during query time Woudl it be possible to do some sort of half-way solution, like maybe allow up to 4 window functions, and above that turn off the optimization? |
findepi
commented
Sep 18, 2025
We can do that but it would feel like a lipstick. I really hope #17624 is addressed. @berkaysynnada knows how to fix this properly without half-means like cutoff. Let's not invest time in a solution that's going to be superseded soonish. |
I agree having a cutoff is a (very) non ideal solution and I also hope we can fix #17624 asap. The reason I don't like the idea of just turning off the optimization for everyone, is if I imagine this change from a user perspective:
I would very much feel like this is a pretty major regression for me The reason I proposed the cutoff is to reduce the number of users who are affected.
I understand that whatever value of cutoff we pick may still result in some people hitting a regression, but I think by picking a reasonable cutoff we'll avoid most problems |
findepi
commented
Sep 18, 2025
planning time gets considerable around 8 columns, IIRC. |
findepi
commented
Sep 18, 2025
Any exponential cost in the planner (or anywhere else) should be considered an absolute no-go and removed promptly. I can take a look whether adding a cutoff is easy. I am worried, however, that the added complexity can mask bugs. With cutoff of |
83bee08 to
39a3647Comparefindepi
commented
Sep 18, 2025
Added cutoff at the cost of test coverage. |
berkaysynnada
commented
Sep 19, 2025
tbh, not loving this workaround. If it can wait till this weekend, I can implement the actual fix I talked about earlier |
alamb
commented
Sep 19, 2025
I think we can wait a few more days. Thank you @berkaysynnada 🙏 |
Before the change, the planning time was exponential with respect to number of columns used in window partitioning clause.
This is a stop-gap solution to avoid exponential planning time.
Which issue does this PR close?
Rationale for this change
Exponential planning time is not acceptable
What changes are included in this PR?
Reduce optimization eagerness to avoid exponential planning time
Are these changes tested?
benchmarks added in
Are there any user-facing changes?
i don't think so