You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/04/19 23:25:35 UTC

(datafusion) branch main updated: perf: Tweak vec capacity in `project_statistics` (#21734)

This is an automated email from the ASF dual-hosted git repository.

github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 03ca0aa301 perf: Tweak vec capacity in `project_statistics` (#21734)
03ca0aa301 is described below

commit 03ca0aa3019ec1b118bb25dccadc469ebe6aa986
Author: Neil Conway <ne...@gmail.com>
AuthorDate: Sun Apr 19 19:23:20 2026 -0400

    perf: Tweak vec capacity in `project_statistics` (#21734)
    
    ## Which issue does this PR close?
    
    N/A
    
    ## Rationale for this change
    
    We can easily specify the correct capacity for the result vector in
    `project_statistics`. Profiling shows that this reduces total allocated
    bytes for planning TPC-H Q13 by ~1.7%, or ~17 kB out of ~1.03MB of
    allocations.
    
    Probably too small to show up in a measurement of elapsed duration, but
    doesn't hurt.
    
    ## What changes are included in this PR?
    
    * Specify vector capacity in `project_statistics`
    
    ## Are these changes tested?
    
    Yes.
    
    ## Are there any user-facing changes?
    
    No.
---
 datafusion/physical-expr/src/projection.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/datafusion/physical-expr/src/projection.rs b/datafusion/physical-expr/src/projection.rs
index ed4f2ff0bd..62c4d42570 100644
--- a/datafusion/physical-expr/src/projection.rs
+++ b/datafusion/physical-expr/src/projection.rs
@@ -656,7 +656,7 @@ impl ProjectionExprs {
         mut stats: Statistics,
         output_schema: &Schema,
     ) -> Result<Statistics> {
-        let mut column_statistics = vec![];
+        let mut column_statistics = Vec::with_capacity(self.exprs.len());
 
         for proj_expr in self.exprs.iter() {
             let expr = &proj_expr.expr;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org