2010YOUY01 opened a new pull request, #17562: URL: https://github.com/apache/datafusion/pull/17562
## 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 #123` indicates that this PR will close issue #123. --> - Closes https://github.com/apache/datafusion/issues/17547 ## 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. --> See the issue for the background. If the optimizer made the wrong join order decision, and put a very small input at the probe side of NLJ, the NLJ operator now can handle it much faster than before. For implementation, before it's always handling `(one_left_row X right_batch)` in the inner loop, this PR do join multiple left rows at once with the right batch, if the right batch is very small. The NLJ microbench result, only Q13 is for this workload: ``` ┏━━━━━━━━━━━━━━┳━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓ ┃ Query ┃ before ┃ improve-nlj-small-right ┃ Change ┃ ┡━━━━━━━━━━━━━━╇━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩ │ QQuery 1 │ 85.31 ms │ 85.75 ms │ no change │ │ QQuery 2 │ 111.36 ms │ 109.88 ms │ no change │ │ QQuery 3 │ 180.99 ms │ 181.56 ms │ no change │ │ QQuery 4 │ 340.38 ms │ 355.24 ms │ no change │ │ QQuery 5 │ 248.62 ms │ 231.90 ms │ +1.07x faster │ │ QQuery 6 │ 1680.89 ms │ 1682.07 ms │ no change │ │ QQuery 7 │ 233.65 ms │ 234.83 ms │ no change │ │ QQuery 8 │ 1679.12 ms │ 1675.63 ms │ no change │ │ QQuery 9 │ 266.52 ms │ 266.54 ms │ no change │ │ QQuery 10 │ 544.66 ms │ 544.71 ms │ no change │ │ QQuery 11 │ 274.43 ms │ 265.71 ms │ no change │ │ QQuery 12 │ 275.11 ms │ 274.72 ms │ no change │ │ QQuery 13 │ 76.56 ms │ 1.88 ms │ +40.70x faster │ └──────────────┴────────────┴─────────────────────────┴────────────────┘ ``` In DF49 it's around 4ms. ## 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. --> - Added one microbench query targeting small right input workload - Added one branch in the NLj's right input handling logic: if the current right batch is very small, try to join it with multiple left rows. ## 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)? --> This can be covered by existing tests: this additional path is not only triggered if the entire right input is small. For regular workloads, the final input batch can be also very small, so this new path can be triggered and tested. ## Are there any user-facing changes? <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. --> <!-- If there are any breaking changes to public APIs, please add the `api change` label. --> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
