-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add a fast path for optimize_projection
#15746
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
Conversation
optimize_projection
cd85701 to
f62173e
Compare
goldmedal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xudong963 LGTM.
I ran the clickbecnh_1 to ensure the long projection case won't be slower.
Comparing speed_up_optimize_projection-disable and speed_up_optimize_projection
--------------------
Benchmark clickbench_1.json
--------------------
┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query ┃ speed_up_optimize_projection-disable ┃ speed_up_optimize_projection ┃ Change ┃
┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0 │ 0.21ms │ 0.27ms │ 1.29x slower │
│ QQuery 1 │ 26.94ms │ 27.52ms │ no change │
│ QQuery 2 │ 53.18ms │ 50.71ms │ no change │
│ QQuery 3 │ 46.54ms │ 46.98ms │ no change │
│ QQuery 4 │ 306.56ms │ 296.81ms │ no change │
│ QQuery 5 │ 435.87ms │ 430.61ms │ no change │
│ QQuery 6 │ 0.20ms │ 0.20ms │ no change │
│ QQuery 7 │ 29.09ms │ 30.44ms │ no change │
│ QQuery 8 │ 356.99ms │ 351.61ms │ no change │
│ QQuery 9 │ 508.16ms │ 506.84ms │ no change │
│ QQuery 10 │ 124.69ms │ 128.00ms │ no change │
│ QQuery 11 │ 146.35ms │ 148.31ms │ no change │
│ QQuery 12 │ 469.04ms │ 467.58ms │ no change │
│ QQuery 13 │ 563.89ms │ 587.40ms │ no change │
│ QQuery 14 │ 437.09ms │ 434.55ms │ no change │
│ QQuery 15 │ 352.85ms │ 357.64ms │ no change │
│ QQuery 16 │ 809.19ms │ 827.07ms │ no change │
│ QQuery 17 │ 737.81ms │ 737.52ms │ no change │
│ QQuery 18 │ 2107.86ms │ 1865.77ms │ +1.13x faster │
│ QQuery 19 │ 44.79ms │ 44.96ms │ no change │
│ QQuery 20 │ 639.96ms │ 624.59ms │ no change │
│ QQuery 21 │ 747.94ms │ 793.88ms │ 1.06x slower │
│ QQuery 22 │ 1480.86ms │ 1533.00ms │ no change │
│ QQuery 23 │ 4606.85ms │ 4562.09ms │ no change │
│ QQuery 24 │ 273.64ms │ 267.35ms │ no change │
│ QQuery 25 │ 272.76ms │ 271.14ms │ no change │
│ QQuery 26 │ 303.19ms │ 315.82ms │ no change │
│ QQuery 27 │ 980.59ms │ 980.28ms │ no change │
│ QQuery 28 │ 7661.86ms │ 7857.94ms │ no change │
│ QQuery 29 │ 345.65ms │ 358.20ms │ no change │
│ QQuery 30 │ 383.39ms │ 376.86ms │ no change │
│ QQuery 31 │ 389.84ms │ 395.84ms │ no change │
│ QQuery 32 │ 1705.60ms │ 1648.16ms │ no change │
│ QQuery 33 │ 1816.90ms │ 1898.96ms │ no change │
│ QQuery 34 │ 2069.67ms │ 2047.80ms │ no change │
│ QQuery 35 │ 517.60ms │ 507.64ms │ no change │
│ QQuery 36 │ 79.65ms │ 79.48ms │ no change │
│ QQuery 37 │ 39.88ms │ 39.67ms │ no change │
│ QQuery 38 │ 79.42ms │ 79.24ms │ no change │
│ QQuery 39 │ 131.94ms │ 127.71ms │ no change │
│ QQuery 40 │ 28.20ms │ 29.04ms │ no change │
│ QQuery 41 │ 27.70ms │ 28.23ms │ no change │
│ QQuery 42 │ 26.41ms │ 23.72ms │ +1.11x faster │
└──────────────┴──────────────────────────────────────┴──────────────────────────────┴───────────────┘
|
🤖 |
|
🤖: Benchmark completed Details
|
It doesn't seem to have any obvious influence. |
|
Maybe it possible to run some sql planner benchmarks to quantify the performance improvement for full queries? |
Do we have some existing sql planner benchmarks? |
Yes, there is a sql_planner bench. |
I don't find SQL in the file that has the following pattern |
|
Thank you for your review, let's go and continue to optimize. |
They sometimes might have after a optimization rule that adds one extra projection? Not sure if that happens in those queries though, but always good to test. |
Oh, I'll do it |
Something is broken, will retest after #15762 is fixed |

Which issue does this PR close?
Rationale for this change
If the two projections have same exprs (my real case). We can directly remove the current projection and return the child projection. Avoid really running the
merge_consecutive_projectionsmethod. This would improve performance if the projections have many exprsBenchmark
Benchmark result
What changes are included in this PR?
Add a fast path
Are these changes tested?
By existing tests
Are there any user-facing changes?