Conversation
…ction (MVP)
Stage 2 implements one logical candidate physically: exact Aggregate{[TopK]}
becomes Limit(Sort) per group, summaries stay build -> estimate, every node
runs at query time, and the timed roots export as one PhysicalASAPDAG.
Stage 3 is the only stage that computes cost. It rejects candidates whose
summary misses its query's accuracy target (accuracy model, analytical
guarantee) or uses Count-Min over weights not proven non-negative, prices
every valid candidate node by node with analytical_cost (illustrative
statistics), selects the cheapest and reports the rest as costlier.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add stage2_physical_asap (no cost) and stage3_selection (costs, selected, every other candidate rejected as invalid or costlier) per the v2 contract. PromQL rows carry the series identity from Stage 0, as runtime state needs. Regenerate tools/dag-viewer/examples/planner-layering-example1.json. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#509 Stage 2 turns each logical candidate into a physical one, and Stage 3 is the only stage that uses cost to pick one plan. Before this PR the pipeline stopped at Stage 1, so it selected no plan.
What
physical_candidates::stage2_physical(from_logical, roots)(Stage 2 MVP): one physical candidate for each logical candidate.Aggregate{[TopK]}becomes a per-groupSortfollowed by a per-groupLimit, the shape the PromQL frontend uses for generictopk.MaterializationAssignment, so every summary state is computed at query time. AMaintainPopulationis rejected because it runs only at ingestion time.PhysicalASAPDAG, and a node shared by two roots stays one node.plan_selection(Stage 3): rejects a candidate whose summary misses its query's accuracy target, or that uses Count-Min over weights not proven non-negative. It prices every valid candidate node by node withanalytical_cost(illustrative statistics), selects the cheapest, and reports every other candidate as costlier.stage_pipelinenow also emitsstage2_physical_asapandstage3_selection. The fixture is regenerated.How
Stage 2 rewrites bottom-up with one memo for the whole workload, so sharing between roots is preserved. It then applies
apply_materialization_timingswithMaterializationAssignment::default(); it chooses no materialization. Stage 3 charges each DAG node once, so a shared node costs the same whatever the number of consumers.Example 1
Before this PR:
stage_pipelinestops at 24 Stage 1 candidates, and no plan is chosen.After this PR: the counts are 1 → 24 → 24 → 1.
sort (partition by job) → limit 10.Q1 exact (Sum acc, Rate acc) · Q2 exact (Sum acc), at 79.4 cpu_ms per workload evaluation.Known gaps
The fixture
tools/dag-viewer/examples/planner-layering-example1.jsonwas regenerated after the rebase onto #543. It is byte-identical to the pre-rebase version.🤖 Generated with Claude Code