feat(cost): rank complete physical plan alternatives - #330
Merged
Merged
Conversation
zzylol
force-pushed
the
fix/cost-estimator-invariants
branch
from
September 2, 2026 19:28
44d8dab to
e32d209
Compare
zzylol
force-pushed
the
feat/cost-planner-ranking
branch
2 times, most recently
from
September 3, 2026 02:54
9bc1660 to
39417cd
Compare
zzylol
force-pushed
the
fix/cost-estimator-invariants
branch
from
September 3, 2026 02:54
e32d209 to
9d35b6d
Compare
zzylol
marked this pull request as ready for review
September 3, 2026 03:17
zzylol
force-pushed
the
fix/cost-estimator-invariants
branch
from
September 3, 2026 16:13
9d35b6d to
9d7dfc2
Compare
zzylol
force-pushed
the
feat/cost-planner-ranking
branch
from
September 3, 2026 16:13
4356990 to
2886b84
Compare
zzylol
force-pushed
the
feat/cost-planner-ranking
branch
from
September 3, 2026 23:54
86025bb to
fa499a1
Compare
zzylol
changed the base branch from
fix/cost-estimator-invariants
to
feat/cost-promql-stack-linear
September 3, 2026 23:54
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
Logical candidate ranking is valid only when raw and post-ASAP alternatives cover the same target, source contents, predicates, event-time range, recurrence, and workload horizon. Partial plans or statistics from different snapshots must not enter one comparison.
The implementation must also distinguish the physical plan being estimated from the analytical method used to estimate it. Physical operator identities and evidence are inputs; CPU, memory, and I/O formulas are analytical predictions rather than runtime measurements.
What
PhysicalPlanCostModelat the final planner-selection boundary.PhysicalEvidenceSnapshotper target; blank or whitespace-only versions fail before any evidence lookup.Mechanism
The modules expose four distinct responsibilities:
query_physical_loweringrecursively mapsQueryExprand logical rewrites to physical operators.physical_operator_statisticsdefines the per-operator catalog/runtime evidence contract.analytical_costapplies algorithmic formulas to anEvidenceBackedPhysicalDagand composes CPU, peak-memory, and source-I/O estimates.physical_plan_cost_modelcompares complete raw and replacement physical alternatives at the planner-ranking boundary.SummaryExprcandidates are bound byPlannerPhysicalPlanProvider, because implementation-specific summary operators and retained state require physical evidence. Raw and replacement DAGs are estimated against the exact sameComparisonScopeand snapshot version.EvidenceBackedPhysicalDagis the single shared physical DAG representation; query lowering does not publish a secondPhysicalDagalias. No structural node count or optimistic zero is used by this analytical selection path.The self-contained design and formula contract are documented in
docs/design_docs/asap-aware-mapping/analytical-resource-cost.md; physical lowering integration is documented separately inphysical-plan-integration.md.Validation
cargo test -p asap-aware-mappingcargo clippy --workspace --all-targets --all-features -- -D warningscargo fmt --all -- --checkStack: based on #328; #331 adds streaming-summary resource modeling.