-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug Report: vtgate planning performance regression for big "union" since v15 #17467
Comments
I did another round of benchmarking.
Suggestions: |
Thank you @czhang1216 for reporting and providing all the relevant details. |
Hi there 👋 So, in
However, in
And when comparing the cached
Since we don't backport performance optimisations to older releases, I don't think there is much to do here. |
@systay I'm sorry I don't see you comparing the performance between main and 15. In my test main is slightly better than 19, but is still visibly worse than 15. Could you address this? |
Hi again @czhang1216! 👋 Thank you for clarifying the difference you’re seeing between
Part of the reason is that our newer planner now does more extensive analysis—especially around merging UNION sub-queries—so we end up investing additional computation time. For most workloads, we expect the plan cache to spread that cost out across many runs, making it less noticeable. Does the plan cache help in your scenario, or are you seeing this as a persistent bottleneck? |
Hi @systay, thanks for your suggestion. I think there are some performance problems, even when we are able to mitigate with query plan caching. For my 50-union query on Secondly, long unions creates very deep stack. And golang is not good at handling that. golang pprof default stack size is 64 and go has no tail recursion. I'd suggesting folding |
@czhang1216 what made you focus on the planning time? Is it a significant proportion of overall query time? |
Yes the plan time is significant, in real world, when we read ~50 rows out of ~20 shards (all microbenchmark above is single shard), the vtgate plan time is 50+% of overall query time. After v15 it's 2x, sometimes 10x worse, taking a large hit on the total performance. Yes caching mitigates the problem. But still when something is untidy we should clean it up. The flame graph on the 50-subquery union look like this. |
Thanks for the detailed info. We will continue to look into this. |
Hi again @czhang1216 I think @deepthi asked for a flamegraph that includes the running of the query. You are showing only the planning part. |
Overview of the Issue
Continuation from the slack thread. After switching from v15 to v19, we are seeing
2x-3x+2-30x planning performance regression on some particular query. This regression is significant when small amount of data is read.Reproduction Steps
I included our schema and query in question in attached patches. Apply them to v15 and v19 repo, you'll be able to see the performance difference.
Step-by-step reproduce instructions:
15.patch
and19.patch
to an empty directory, then run the following in that directory:The query in question roughly looks like the following. As you can see it has a large
UNION
subquery.(Please ignore the inefficiency of the query itself, it's just for the purpose of displaying planner benchmark regression.
Binary Version
vtgate version Version: 19.0.8 (Git revision 2665aa2a74fdd26c4606598ba68746be30bd9148 branch 'HEAD') built on Tue Dec 3 05:09:55 UTC 2024 by runner@fv-az1670-25 using go1.22.9 linux/amd64
Operating System and Environment details
Log Fragments
No response
The text was updated successfully, but these errors were encountered: