You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Performance]: Prepared ROUND numeric text can disable BIGINT filter pushdown #29512
Performance gap in newly supported prepared numeric text
With #29508, ROUND(?,0) correctly accepts complete fractional/scientific numeric text and returns the expected value. When that result is compared with a selective signed BIGINT key, the planner may cast the key column to DECIMAL128 and lose native block filtering. A text spelling difference that leaves the rounded value unchanged can therefore produce a large latency jump.
Reproduction
On a 100,000-row table with id BIGINT PRIMARY KEY, current #29508 candidate:
PREPARE p FROM'SELECT COUNT(*) FROM t WHERE id=ROUND(?,0)';
SET @v='54321'; EXPLAIN FORCE EXECUTE p USING @v;
-- cast(id AS DOUBLE) comparison, with a block-filter expressionSET @v='54321.0'; EXPLAIN FORCE EXECUTE p USING @v;
-- cast(id AS DECIMAL128(38,0)) comparison, no Block Filter CondSET @v='5.4321e4'; EXPLAIN FORCE EXECUTE p USING @v;
-- same loss of native filtering
100 sequential executions per spelling, one connection/case, same service: '54321' ~0.57 ms/execute; '54321.0' ~9.15 ms; '5.4321e4' ~8.5 ms. All returned the same count of 1. Direct id=ROUND(54321.0,0) also casts the BIGINT column to DECIMAL128, showing that the comparison coercion/optimizer is a shared owner, while #29508 makes this runtime domain reachable from a prepared text parameter.
Correctness constraints
Do not force a BIGINT result overload or cast the rounded result to BIGINT for arbitrary values: fractions, negative precision, overflow, signedness and values near 2^53 / INT64 boundaries can change results. Prove a safe domain per binding, preserve ROUND/TRUNCATE result semantics and cache invalidation, then assert both rows and scan plans. Include TRUNCATE, scalar/derived parameter expressions, casts, binary protocol and a safe-value control.
Follow-up confirms TRUNCATE has the same behavior on the same service/table (100 sequential EXECUTEs each): '54321' ~0.74 ms/execute, '54321.0' ~7.96 ms, and '5.4321e4' ~8.58 ms. Repeated ROUND controls were ~0.61, 8.13, and 8.20 ms respectively. All returned the same count. This is a value-spelling-dependent loss of effective pruning for both functions, not just ROUND.
Activity
XuPeng-SH commentedon Sep 29, 2026
Follow-up confirms
TRUNCATEhas the same behavior on the same service/table (100 sequential EXECUTEs each):'54321'~0.74 ms/execute,'54321.0'~7.96 ms, and'5.4321e4'~8.58 ms. Repeated ROUND controls were ~0.61, 8.13, and 8.20 ms respectively. All returned the same count. This is a value-spelling-dependent loss of effective pruning for both functions, not just ROUND.fix: preserve prepared ROUND and TRUNCATE value domains (#29508)
fix(plan): normalize native ranges and prune prepared rounding filters (
Ariznawlll commentedon Oct 2, 2026
测试版本
maind59cc02ef6ca68f340c9570e56f7eb71d90e42e7原问题验证
构造 100000 行 BIGINT 数据,验证 prepared
id = ROUND(?,0)与id = TRUNCATE(?,0)。.0的完整数值文本、科学计数法绑定均返回正确结果正常路径覆盖
对 integer text、fractional spelling、scientific notation 等安全值分别执行 30 次,ROUND/TRUNCATE 均保持选择性过滤,平均约 0.209–0.258 ms。
同时覆盖 direct、scalar subquery、derived table / CTE 参数传递形态,结果与计划一致。
边界与保守路径覆盖
12345.5按 ROUND/TRUNCATE 各自语义返回正确行,不因优化改变函数结果。0 / -1 / NULL / 0间复用,计划和值均未出现陈旧状态。白盒与 BVT 验证
MatrixOne 现有用例
test/distributed/cases/prepare/issue_29512_round_filter_pushdown.sql连续执行 3 轮均通过。回归测试
已加入 MOTR PR #209,commit
3b4d80060724d3f19c672d9f039c5df951d63c81,用例:suites/14_issue_regression/t/issue_29507_29510_29511_29512_filter_pruning.test14_issue_regression并发套件中该新增用例通过本问题是 prepared 参数域与过滤器生成问题,安全值、函数语义、NULL、precision 复用和保守路径都可由确定性 SQL/计划断言覆盖,不依赖数据规模阈值,因此不另加 big-data。
测试结论
最新 main 中,ROUND/TRUNCATE 的安全数值文本和科学计数法绑定已恢复 BIGINT 原生过滤;边界输入仍保持原函数与比较语义,回归已补充。
测试通过。