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
feat(optimizer): Common sub-plan detection. #7865
Conversation
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.
license-eye has totally checked 2745 files.
Valid | Invalid | Ignored | Fixed |
---|---|---|---|
1299 | 1 | 1445 | 0 |
Click to see the invalid file list
- src/frontend/src/optimizer/plan_node/merge_eq_nodes.rs
The current design requires
|
We have a method |
445fb64
to
f901cc2
Compare
f901cc2
to
575d1cd
Compare
aad841a
to
698862c
Compare
8236ca5
to
de09a81
Compare
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## main #7865 +/- ##
==========================================
+ Coverage 71.62% 71.64% +0.01%
==========================================
Files 1131 1132 +1
Lines 182002 182188 +186
==========================================
+ Hits 130361 130529 +168
- Misses 51641 51659 +18
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
| | ├─LogicalScan { table: partsupp, columns: [partsupp.ps_partkey, partsupp.ps_suppkey, partsupp.ps_availqty, partsupp.ps_supplycost] } | ||
| | └─LogicalScan { table: supplier, columns: [supplier.s_suppkey, supplier.s_nationkey] } | ||
| └─LogicalScan { table: nation, output_columns: [nation.n_nationkey], required_columns: [nation.n_nationkey, nation.n_name], predicate: (nation.n_name = 'ARGENTINA':Varchar) } | ||
| └─LogicalShare { id = 373 } |
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.
TPCH Q11 also benefits from this PR.
optimized_logical_plan: | | ||
LogicalValues { rows: [[1:Int32], [1:Int32]], schema: Schema { fields: [1:Int32:Int32] } } | ||
LogicalUnion { all: true } | ||
├─LogicalShare { id = 90 } | ||
| └─LogicalValues { rows: [[1:Int32]], schema: Schema { fields: [1:Int32:Int32] } } | ||
└─LogicalShare { id = 90 } | ||
└─LogicalValues { rows: [[1:Int32]], schema: Schema { fields: [1:Int32:Int32] } } |
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.
Values is not worth to share.
0f2a168
to
78076eb
Compare
└─StreamNow { output: [now] } | ||
└─StreamProject { exprs: [now], watermark_columns: [now] } | ||
└─StreamShare { id = 94 } | ||
└─StreamNow { output: [now] } |
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.
We shouldn't share Now as well right?
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.
We can share the common sub-plan with the following properties:
- include at least one table scan/ source.
Another interesting observation on nexmark q5. We can share more than just explain (trace) create materialized view v as SELECT AuctionBids.auction, AuctionBids.num FROM (
SELECT
bid.auction,
count(*) AS num,
window_start AS starttime
FROM
HOP(bid, date_time, INTERVAL '2' SECOND, INTERVAL '10' SECOND)
GROUP BY
window_start,
bid.auction
) AS AuctionBids
JOIN (
SELECT
max(CountBids.num) AS maxn,
CountBids.starttime_c
FROM (
SELECT
count(*) AS num,
window_start AS starttime_c
FROM HOP(bid, date_time, INTERVAL '2' SECOND, INTERVAL '10' SECOND)
GROUP BY
bid.auction,
window_start
) AS CountBids
GROUP BY
CountBids.starttime_c
) AS MaxBids
ON AuctionBids.starttime = MaxBids.starttime_c AND AuctionBids.num >= MaxBids.maxn; This snippet can be shared as well. we just need to reorder its SELECT
bid.auction,
count(*) AS num,
window_start AS starttime
FROM
HOP(bid, date_time, INTERVAL '2' SECOND, INTERVAL '10' SECOND)
GROUP BY
window_start,
bid.auction |
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.
LGTM! Great work!
Hey @wsx-ucb, this pull request failed to merge and has been dequeued from the merge train. If you believe your PR failed in the merge train because of a flaky test, requeue it by clicking "Update branch" or pushing an empty commit with |
The failure should have nothing to do with this PR. It's a known issue of Sqlsmith fuzzy testing. |
Too many conflicts. 🥵 |
I hereby agree to the terms of the RisingWave Labs, Inc. Contributor License Agreement.
What's changed and what's your intention?
Attempt to resolve #7360.
Checklist
./risedev check
(or alias,./risedev c
)Documentation
Click here for Documentation
Types of user-facing changes
Please keep the types that apply to your changes, and remove the others.
Release note