NOSSLETTER.techLIVE

Digest

Today's best merged pull request, and the full archive of every day before it.

Compute sibling scalar aggregates over the same table in one pass

Language: C+++2234 -4performance
concepts demonstrated
Query optimizationScalar aggregate functionsTable functionsConditional rewrite rules
The Issue & Context

Queries with multiple scalar aggregates over the same file or table function scanned the data multiple times—once per aggregate—causing redundant expensive IO for Parquet, CSV, and JSON inputs.

Root Cause Analysis

Each scalar aggregate subquery independently triggered a full scan of the underlying table function or file, because the optimizer lacked a rewrite to combine these sibling aggregates into a single scan with FILTER clauses. The old plan duplicated scan effort instead of sharing it.

Solution Strategy & Architectural Pattern

Introduced a new optimizer rule `scalar_aggregate_merge` that detects sibling scalar aggregates over the same table function or large catalog tables and merges them into one scan with per-aggregate FILTER predicates. This rewrite is gated by a configurable threshold to avoid regressions on native DuckDB tables where FILTER overhead outweighs scan savings. The implementation tracks identical table function calls and merges their aggregates in `scalar_aggregate_merger.cpp`.

Key Takeaway for Contributors

When multiple aggregates scan the same data independently, merging them into a single scan with conditional aggregation can drastically reduce IO and improve performance, but only if the overhead of filtering does not outweigh the saved scans—making cost-based gating essential.

[ 01 // ARCHIVE ]

73 entries — page 1 of 4
DateRepositoryScore
2026-11-03ggml-org/llama.cpp9/10read →full digest →
2026-11-02vllm-project/vllm9/10read →full digest →
2026-11-01vllm-project/vllm9/10read →full digest →
2026-10-31vllm-project/vllm9/10read →full digest →
2026-10-30cilium/cilium9/10read →full digest →
2026-10-29milvus-io/milvus9/10read →full digest →
2026-10-28ggml-org/ggml9/10read →full digest →
2026-10-27milvus-io/milvus9/10read →full digest →
2026-10-26ClickHouse/ClickHouse9/10read →full digest →
2026-10-25vllm-project/vllm8/10read →full digest →
2026-10-24python/cpython9/10read →full digest →
2026-10-23milvus-io/milvus9/10read →full digest →
2026-10-22milvus-io/milvus9/10read →full digest →
2026-10-21milvus-io/milvus9/10read →full digest →
2026-10-20nodejs/node8/10read →full digest →
2026-10-19vllm-project/vllm9/10read →full digest →
2026-10-18ggml-org/llama.cpp9/10read →full digest →
2026-10-17ggml-org/llama.cpp9/10read →full digest →
2026-10-16huggingface/transformers9/10read →full digest →
2026-10-15microsoft/vscode8/10read →full digest →
← prev1 / 4next →