Skip to content

Commit 03ca0aa

Browse files
authored
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.
1 parent 675881d commit 03ca0aa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

datafusion/physical-expr/src/projection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ impl ProjectionExprs {
656656
mut stats: Statistics,
657657
output_schema: &Schema,
658658
) -> Result<Statistics> {
659-
let mut column_statistics = vec![];
659+
let mut column_statistics = Vec::with_capacity(self.exprs.len());
660660

661661
for proj_expr in self.exprs.iter() {
662662
let expr = &proj_expr.expr;

0 commit comments

Comments
 (0)