adriangb commented on code in PR #18393:
URL: https://github.com/apache/datafusion/pull/18393#discussion_r2552634204


##########
datafusion/common/src/config.rs:
##########
@@ -1019,6 +1019,22 @@ config_namespace! {
         /// will be collected into a single partition
         pub hash_join_single_partition_threshold_rows: usize, default = 1024 * 
128
 
+        /// Maximum size in bytes for the build side of a hash join to be 
pushed down as an InList expression for dynamic filtering.
+        /// Build sides larger than this will use hash table lookups instead.
+        /// Set to 0 to always use hash table lookups.
+        ///
+        /// InList pushdown can be more efficient for small build sides 
because it can result in better
+        /// statistics pruning as well as use any bloom filters present on the 
scan side.
+        /// InList expressions are also more transparent and easier to 
serialize over the network in distributed uses of DataFusion.
+        /// On the other hand InList pushdown requires making a copy of the 
data and thus adds some overhead to the build side and uses more memory.
+        ///
+        /// This setting is per-partition, so we may end up using 
`hash_join_inlist_pushdown_max_size` * `target_partitions` memory.
+        ///
+        /// The default is 128kB per partition.
+        /// This should allow point lookup joins (e.g. joining on a unique 
primary key) to use InList pushdown in most cases
+        /// but avoids excessive memory usage or overhead for larger joins.
+        pub hash_join_inlist_pushdown_max_size: usize, default = 128 * 1024

Review Comment:
   Yeah that's the idea. As the build side gets larger:
   - It becomes more expensive to build the InListExpr (I think we can make it 
cheaper but it will probably always be more expensive than copying a reference)
   - It's less likely optimizations like bloom filters will help. In fact, 
bloom filters will only be hit with < 20 items (this is set deep in the 
PruningPredicate code)
   
   So at some point it makes sense to cut the losses and go through each row 
with the hash table.
   
   The `InListExpr` approach is going to shine when there is a point lookup 
type query (i.e. one row from the build side) that can hit a bloom filter on 
the probe side.



-- 
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]

Reply via email to