Repository navigation
Print the q-error of each join side's estimated rows in EXPLAIN ANALYZE - #131313
alexey-milovidov merged 2 commits into
Conversation
`EXPLAIN ANALYZE` printed a q-error only for a join's output rows. The `Left:` and `Right:` lines already carry the join-order optimizer's estimate of each input next to its actual rows, but without a q-error, so the worst estimates (a filtered table read whose filter estimate is far off) had to be computed by hand. Each side line now reads `rows estimated E · rows A · q-error Q · matched ...`, using the same `resultRowsQError` (max(E / A, A / E)) and the same metric as `Output rows`. It is absent when the estimate is missing or 0 or the side read no rows. This is where the planner uses a filter estimate: a filtered table read is a leaf of the join graph, estimated by `estimateReadRowsCount` in `optimizeJoin.cpp`, and the side estimate printed here is the one join reordering used, including the hash-table cache override. Recomputing an estimate for `Filter` steps at EXPLAIN time would print a number nothing used. Join runtime filters lower a side's actual rows without any estimation error; the docs say so and name `enable_join_runtime_filters = 0` to compare the estimate alone. Related: ClickHouse#123553 Co-Authored-By: Claude Opus 5.5 <[email protected]>
05629 covered an exact estimate and an overestimate (500 estimated, 20 read), so a one-sided `estimated / actual` ratio would still pass. Add `WHERE d.s = 'common'` (500 estimated, 980 read, q-error 1.96): the underestimate direction, which is the direction of the filter errors reported on ClickHouse#123553. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 1 finding over 2 rounds, 0 on the final delta) plus my own review (0 blocker/major).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261113-131400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-41:20261113-114300 |
|
Workflow [PR], commit [80d8dde] Summary: ✅
AI ReviewSummaryAdds per-input cardinality q-error to Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units8 translation units recompiled, 11 s compile time in total, 8 of them have a recent master baseline. |
032dcfb
Related: #123553
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
EXPLAIN ANALYZEnow prints the q-error of the estimated rows of each join input next torows estimatedandrows; for a filtered table read this is the q-error of its filter estimate.Description
Asked for on #123553 (#123553 (comment)): filter estimates had no q-error in
EXPLAIN ANALYZE. @ m-selmi suggested the same when approving #114792.EXPLAIN ANALYZEprinted a q-error only for a join'sOutput rows. TheLeft:andRight:lines already show the join-order optimizer's estimate of each input and its actual rows; they now also show the q-error, computed by the sameresultRowsQError(max(estimated / actual, actual / estimated)):It is printed on the join inputs because that is where the planner uses a filter estimate: a filtered table read is a leaf of the join graph, estimated by
estimateReadRowsCount, and the printed side estimate is exactly the one join reordering used (including the hash-table statistics override). AFilterstep outside a join has no estimate that anything uses. As withOutput rows, the q-error is omitted when the estimate is missing or either value is 0. Join runtime filters lower the actual rows of the side they prune, which no estimate accounts for; the docs say so and nameenable_join_runtime_filters = 0.The output docs are updated in
ParserExplainQuery.cpp. New test05629_explain_analyze_join_side_q_errorfails on master and passes here (50/50 with random settings); all 35 stateless tests usingEXPLAIN ANALYZEpass unchanged.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/131313]
Version info
26.11.1.2273-master(included in26.11and later)