Skip to content

[Subtask]: Reuse repeated aggregate producers and filter before wide joins in Q15-shaped plans #30842

Open

Description

@aunjgr

Parent Issue

#30838

Detail of Subtask

Evidence reassessment — 2026-10-26

Current delivery/performance status: DESIGN/VALIDATION OPEN. The plan/work-count observation remains useful; no producer-reuse-only production speedup has been demonstrated.

Observed: Pinned Q15 has two MO LINEITEM/revenue producers; DuckDB materializes one common producer and filters winning revenue before wide supplier fetch. A historical RANK rewrite changes MO SF100 from 10.592 to 5.945 s, but changes reuse, filter placement and sorting together.

Not yet established: How much each separate transformation saves on current main and when sharing costs more memory, synchronization or startup than recomputation.

Next discriminating experiment: Rebaseline the unchanged create-view/SELECT/drop-view lifecycle. Compare existing reuse eligibility and work counts, then isolate reuse-only and early-filter variants before combining them. Include materialization and consumer wait costs.

Measured target: One eligible expensive producer and reduced wide materialization for unchanged Q15-shaped SQL, followed by query CPU/latency and full-suite acceptance.

Mandatory controls and total cost boundary: Ties, empty/NULL aggregates, volatile or merely similar producers, selective/unselective consumers, tiny input, memory pressure and cancellation/early stop.

Performance acceptance and rejection

  • Freeze current-main/candidate sources, executables, real caller shapes and effective settings. Use the unchanged qualification SQL and complete result consumption; exclude cold runs and keep profiles separate from latency scoring.
  • Demonstrate the named work/CPU reduction and an attributable uninstrumented target-query improvement. Include the controls below and full Q1-Q22 comparison; component wins, source changes, functional tests, SCA, merging and profile percentages are separate evidence.
  • A confirmed affected/control slowdown fails; unresolved slower signals are inconclusive. Confirm with an independent longer balanced run. No gain elsewhere, favorable average or self-approved tolerance waives a regression.
  • Complete applicable SF10/SF100 and memory/mixed-I/O acceptance before issue closure under the umbrella protocol. Report uncertainty, absolute CPU/instructions/work, allocations/copies and the same whole-application budget, effective cache, I/O/spill/swap/pressure evidence. Benchmark scripts do not verify input/table/schema/row counts/reference results/checksums.

Semantics and lifecycle requirements retained

  • The unchanged Q15-shaped SQL produces one eligible expensive revenue producer, with native work counts demonstrating reuse.
  • Independent small tests cover ties, empty inputs, NULL aggregate/scalar-subquery behavior, volatile expressions and view lifetime.
  • Reused state has explicit ownership, memory accounting and release on completion, error, cancellation and operator reuse.
  • Report separate reuse-only/filter-placement controls where feasible, then warmed Q15 latency/CPU and the full-suite effect; preserve an ineligible/cost-negative fallback.

Describe implementation you've considered

Extend existing deterministic producer reuse where an equivalent eligible plan is missed. Evaluate early winner filtering separately. Keep recomputation or existing inlining when sharing is cost-negative; no new general materialization framework without need.

Coordination: Coordinate with #30857 but do not equate repeated identical producers with grouped-measure reuse through joins.

Additional information

Pinned implementation / plan references

Activity

  1. self-assigned this
    on Oct 22, 2026
  2. added
    severity/s0
    on Oct 22, 2026
  3. assigned and unassigned on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/subtaskseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions