Repository navigation
Description
Summary
perf(plan): expose safe subquery predicates before join costing (#27915,
merge commit 14886c222ff94a4c3f1ee386f9f40fb22c3b5056) can regress the standard
TPCH Q19 predicate from a keyed hash join to a CPU-bound LoopJoin when the
planner is cold. The equality part.p_partkey = lineitem.l_partkey appears in
every OR branch, but the regressed path leaves the complete DNF expression as
the join condition rather than exposing the equality as the hash key and
retaining the branch-specific predicates as a residual filter.
This is a production-performance correctness issue: it changes a linear-ish
keyed join into work that grows catastrophically with the filtered inputs.
User-visible impact
Current scheduled AP campaign:
- mo-auto-test run 33649628042 / AP job, MatrixOne
90de439666179fda46dae9c9f5fa50fdb20cb213. - TPCH-1G: 2m30s, versus 1m14s in the preceding good campaign.
- TPCH-10G: 2h28m34s, versus 2m34s in the preceding good campaign (~58x for the complete case).
- TPCH-100G remained in Q19 for more than seven hours; the comparable pre-regression nightly Q19 completed in about 4.6s.
The failure is not an I/O stall or deadlock. A live Q19 sample showed the
execution goroutines runnable and CPU-saturated in LoopJoin.
Regression boundary and causal evidence
Good reference: a2d9070974cd42fc11ac530e52f962a696df9089.
Bad subject: 90de439666179fda46dae9c9f5fa50fdb20cb213.
Among the intervening changes, #27915 is the change that modifies the
predicate-distribution / cross-relation DNF path. On the same data and service,
setting:
SET SESSION optimizer_hints = 'subqueryPredicatePlanning=1';restores the old plan shape:
Join Type: INNER hashOnPK
Join Cond: (lineitem.l_partkey = part.p_partkey)
Filter Cond: <the three Q19 OR branches without the equality>
The default bad path instead retains the repeated full OR expression as the
join condition. This is a single-variable control using the compatibility
switch introduced by #27915.
Local black-box reproduction (exact TPCH SF=1)
Environment: locally built 90de4396, fresh MatrixOne process, real TPCH
schema/data, standard Q19 SQL.
| Item | Value |
|---|---|
part rows |
200,000 |
lineitem rows |
6,001,215 |
| Default cold first execution | 20.06s |
| Compatibility-switch cold first execution | 0.20s |
| Result, both paths | 4028540.3287 |
| Default process CPU while slow | ~925% |
The issue is therefore observable at SF=1 without a synthetic query or a
10G fixture. Repeating after planning/statistics have warmed can hide it, so a
test that only reuses a warm service is insufficient.
Root cause / violated invariant
For a join predicate in DNF, if every disjunct contains the same deterministic,
total, cross-relation equality L.key = R.key, planning must retain that
equality as a join key. It may only remove the equality from each residual
branch after proving equivalence.
Q19 has exactly this shape:
(L.key = R.key AND L-only filter A AND R-only filter A)
OR (L.key = R.key AND L-only filter B AND R-only filter B)
OR (L.key = R.key AND L-only filter C AND R-only filter C)
The desired normalized form is:
JOIN ON L.key = R.key
FILTER (branch A without equality OR branch B without equality OR branch C without equality)
The #27915 path changes predicate distribution/exposure before join costing.
On the affected cold-planning route it prevents the common equality from being
available as a keyed join condition, which lets physical planning select
LoopJoin.
Immediate workaround
Set this per session before the workload:
SET SESSION optimizer_hints = 'subqueryPredicatePlanning=1';This rolls back the full #27915 predicate-planning cohort for that session; it
is containment, not the desired permanent fix.
Required fix
Repair the common cross-relation DNF-equality extraction/retention boundary so
that valid common equi-keys remain available to join classification and costing
on every planning state, including a new process and cold statistics. Do not
special-case TPCH/Q19 values or merely force HashJoin: the rewrite must preserve
SQL semantics and retain the legacy path whenever common-key extraction is not
provably safe.
Acceptance criteria
- A focused planner test proves that a deterministic common cross-relation
equality in every DNF arm is emitted as the join key, with the equality
removed only from the equivalent residual predicate. - Counterexamples retain the original semantics/path: no common equality,
equality missing from one arm, non-equality predicates, nullable/three-valued
cases, volatile or fallible expressions, and different cross-relation keys. - A public SQL regression uses the Q19-shaped two-table schema and asserts
result equivalence with the compatibility-switch control; it must exercise a
fresh service or another deterministic cold-planning boundary. - The physical plan for the eligible Q19 shape contains a keyed hash join,
not LoopJoin. Assert stable semantic operator/key properties, not timing. - Re-run real TPCH SF=1 Q19 cold: default and control return the same result,
and default no longer exhibits the ~100x first-run regression. - Validate TPCH 10G/100G campaign behavior after the focused fix; no global
disabling of the perf(plan): expose safe subquery predicates before join costing #27915 cohort and no regression of its intended MARK,
EXISTS, scalar, or DNF behavior.
Related
- perf(plan): expose safe subquery predicates before join costing #27915
- The in-progress TPCH AP run above
Activity
Ariznawlll commentedon Sep 3, 2026
tke性能已经恢复,明天更新单机性能
Ariznawlll commentedon Sep 4, 2026
https://github.com/matrixorigin/mo-nightly-regression/actions/runs/33849479334/job/100959629665
已修复