-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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.
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 <[email protected]>
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