-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: Add selectivity metric to NestedLoopJoinExec for EXPLAIN ANALYZE #18481
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
| // Selectivity Metric: Update total possibilities for the batch (left_rows * right_rows) | ||
| if let (Ok(left_data), Some(right_batch)) = | ||
| (self.get_left_data(), self.current_right_batch.as_ref()) | ||
| { | ||
| let left_rows = left_data.batch().num_rows(); | ||
| let right_rows = right_batch.num_rows(); | ||
| self.metrics.selectivity.add_total(left_rows * right_rows); | ||
| } |
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.
I originally tried to get the values and calculate num_left * num_right at the end (in a drop() method, similar to how it was done here for BuildProbeJoinMetrics. But found it difficult to get the correctness consistently right since these are all multiple streams.
Instead, I'm doing it incrementally. The basic idea here is that for each right batch, we add_total() the size of the full left buffer times the num_rows in the current batch. Doing that num_batches times gives us the equivalent of num_right * num_left.
| self.metrics.join_metrics.output_batches.add(1); | ||
|
|
||
| // Update output rows for selectivity metric | ||
| let output_rows = batch.num_rows(); | ||
| self.metrics.selectivity.add_part(output_rows); |
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.
Update output_rows at flush time.
2010YOUY01
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.
LGTM, thank you!
Co-authored-by: Yongting You <2010youy01@gmail.com>
apache#18481) ## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes apache#123` indicates that this PR will close issue apache#123. --> - Closes apache#18407 ## Rationale for this change <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> This new metric will give the user better visibility to see what portion of the possibilities is actually being matched. ## What changes are included in this PR? <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> Add selectivity metric to NestedLoopJoinExec for EXPLAIN ANALYZE ## Are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Added tests ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> Yes, new metric in explain analyze <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> --------- Co-authored-by: Yongting You <2010youy01@gmail.com>
Which issue does this PR close?
selectivitymetrics (forExplain Analyze) in Nested Loop Join #18407Rationale for this change
This new metric will give the user better visibility to see what portion of the possibilities is actually being matched.
What changes are included in this PR?
Add selectivity metric to NestedLoopJoinExec for EXPLAIN ANALYZE
Are these changes tested?
Added tests
Are there any user-facing changes?
Yes, new metric in explain analyze