Skip to content

perf(planner): collapse topk(sum by ...) into CMS-with-heap #744

Description

@milindsrivastava1997

Goal

Optimize the already-correct query-time implementation of:

topk(k, sum by (...) (metric))

into one CountMinSketchWithHeap precompute.

Intended plan

  • Use CountMinSketchWithHeap.
  • Set its aggregated labels to the inner sum by (...) labels.
  • Use sum weighting/subtype.
  • Emit no query-time aggregation pipeline for this optimized shape.

Prerequisite

The generic nested-aggregation path must exist first, with sum by (...) (metric) as the planned anchor and query-time topk. It is the correctness baseline for this optimization.

Validation

Benchmark the CMS-with-heap path against that baseline and retain Prometheus-equivalence coverage.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions