andygrove opened a new pull request, #4926:
URL: https://github.com/apache/arrow-datafusion/pull/4926

   # 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/arrow-datafusion/issues/4925
   
   See issue for full description of the problem that this PR resolves.
   
   # Rationale for this change
   
   Why repartition twice when we can repartition once?
   
   ## Test Approach
   
   ```bash
   ./target/release/tpch benchmark datafusion --format parquet --partitions 48 
--path /mnt/bigdata/tpch/sf10-parquet/ --query 2 --iterations 10 --debug
   ```
   
   ## Before
   
   Before this PR we have 2 instances of `RepartitionExec` in the plan for each 
table that is an input to a join.
   
   ```
                                 CoalesceBatchesExec: target_batch_size=8192, 
metrics=[output_rows=0, elapsed_compute=20.396µs, spill_count=0, 
spilled_bytes=0, mem_used=0]
                                   RepartitionExec: partitioning=Hash([Column { 
name: "r_regionkey", index: 0 }], 48), metrics=[fetch_time=69.603684ms, 
send_time=48ns, repart_time=48ns]
                                     RepartitionExec: 
partitioning=RoundRobinBatch(48), metrics=[fetch_time=479.696µs, send_time=1ns, 
repart_time=1ns]
                                       CoalesceBatchesExec: 
target_batch_size=8192, metrics=[output_rows=0, elapsed_compute=320ns, 
spill_count=0, spilled_bytes=0, mem_used=0]
                                         FilterExec: r_name@1 = EUROPE, 
metrics=[output_rows=0, elapsed_compute=1ns, spill_count=0, spilled_bytes=0, 
mem_used=0]
                                           ParquetExec: ...
   ```
   
   Query time before this PR:
   
   ```
   Query 2 avg time: 479.53 ms
   ```
   
   ## After
   
   ```
                                 CoalesceBatchesExec: target_batch_size=8192, 
metrics=[output_rows=0, elapsed_compute=6.855µs, spill_count=0, 
spilled_bytes=0, mem_used=0]
                                   RepartitionExec: partitioning=Hash([Column { 
name: "r_regionkey", index: 0 }], 48), metrics=[fetch_time=322.318µs, 
send_time=1ns, repart_time=1ns]
                                     CoalesceBatchesExec: 
target_batch_size=8192, metrics=[output_rows=0, elapsed_compute=281ns, 
spill_count=0, spilled_bytes=0, mem_used=0]
                                       FilterExec: r_name@1 = EUROPE, 
metrics=[output_rows=0, elapsed_compute=1ns, spill_count=0, spilled_bytes=0, 
mem_used=0]
                                         ParquetExec: ...
   ```
   
   Query time after this PR:
   
   ```
   Query 2 avg time: 457.25 ms
   ```
   
   
   # What changes are included in this PR?
   
   New physical optimizer rule
   
   <!--
   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.
   -->
   
   # 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)?
   -->
   
   # 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]

Reply via email to