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]: [4.2-dev] Exact scalar IVF PRE is 10–15× slower with ~8K wide VARCHAR keys after #33514 #33549
Broad scalar filters on IVFFLAT PRE became substantially slower after #33514 when the candidate set contains wide VARCHAR primary keys. The returned Top-10 was correct in every timed execution. Related correctness issues are #33504 and #33531.
Reproduction
Single Linux amd64 CN, four IVF lists, probe_limit=4, 8,300 rows with 1,021-byte primary keys. Run the queries through a persistent SQL connection.
CREATEDATABASEqa_vecwide;
USE qa_vecwide;
CREATETABLEv (id VARCHAR(1100) PRIMARY KEY, seq INT, v VECF32(2));
INSERT INTO v
SELECT CONCAT(LPAD(result,6,'0'),REPEAT('a',1015)), result,
CAST(CONCAT('[',result,',0]') AS VECF32(2))
FROM GENERATE_SERIES(1,8300) g;
CREATEINDEXvi USING IVFFLAT ON v(v) LISTS=4 OP_TYPE 'vector_l2_ops';
SET probe_limit=4;
SELECT seq FROM v WHERE seq BETWEEN 1AND8192ORDER BY l2_distance(v,'[0,0]') LIMIT10 BY RANK WITH OPTION 'mode=pre';
Repeat with the upper bound 8193 and with mode=force as the exact relational control. Consume the entire result and verify seq=1..10. The numbers are medians in milliseconds from eight timed trials per cell after two warmups, alternating the mode order.
Eligible keys
PRE before 95679da6cf
PRE at cc55300698
FORCE before
FORCE at cc55300698
8192
23.163
229.432 (9.9×)
1.651
1.540
8193
15.648
235.177 (15.0×)
1.604
1.576
These are adjacent commits across #33514. Two additional runs on 34b63d7261 measured 258–332 ms in PRE. The fixture covers the 8192-key boundary, and the serialized byte limit can independently split wide-key batches.
Code path and expected result
VisitExactPkFilters serializes the candidate PKs as SQL literals, then the exact search visitor executes an index query per predicate batch, reads qualifying rows and merges the exact Top-K. This introduces serialization, repeated SQL execution and intermediate row processing. The timing comparison does not quantify how much each stage contributes.
Keep exact membership before the final Top-K and bound the overhead for broad candidate sets. Validate short and wide keys, both sides of the row and byte budgets, narrow and broad selectivity, stable membership, OFFSET and empty results. The older PRE timings are a performance baseline; the new path must preserve the correctness guarantees added by #33514.
QA handoff for #33551 on 4.2-dev: tested the immediate pre-fix tree (34b63d72, build 01514ba4) and final merge-equivalent tree (847e6c17, build f1cdc4b5). The pre-fix shared build and fixed shared build both use -cover; source tree, binary version, and downloaded SHA-256 were checked.
Independent Linux/amd64 single-CN MySQL TCP replay of the reported 8,300-row fixture: 1,021-byte VARCHAR keys, four IVF lists, probe_limit=4; 16 alternating timed PRE/FORCE pairs per key count after two warmups. Every result was seq=1..10.
Eligible keys
PRE p50, before → after
FORCE p50, before → after
8,192
408.19 → 32.30 ms
2.74 → 2.55 ms
8,193
386.04 → 36.69 ms
2.65 → 2.72 ms
The same-tree pessimistic multi-CN BVT also ran vector_ivf_pre_exact_domain.sql: 51 passed, zero skipped or failed, including a binary-key page with OFFSET, excluded closer rows, and an empty domain. This verifies the reported slowdown and those controls, not full scale/upgrade acceptance. QA should still challenge concurrent wide-key queries, cancellation, and byte-budget boundaries with larger persisted datasets. #33531 remains a separate issue.
21:47:48.251 TN close logtail service
21:47:48.257 CN clean finished, start to reconnect
21:47:48.264 CN stream is closed on send / rpc stream closed
21:47:48.358 txn client is in pause state, wait for it to be ready
21:47:48.364 TN start logtail service
21:48:17.629 客户端 30 秒查询超时
21:48:17.642 保存 CN goroutine,仍在 forcedSubscribeTable
21:48:17.806 测试清理才发送 SIGTERM
首次业务尝试(整条业务链):30.243590 s,OperationalError 2013 timed out
goroutine:forcedSubscribeTable(1,1),16 个事务等待 waitReadyLocked
后续业务尝试:3.222094 s,COUNT=48000,SUM=1152024000
PRE / FORCE:Top10 完整相等
恢复后四表边界复查:8/8 通过
对应 UTC 服务端日志:
05:07:39.485634 clean finished, start to reconnect
05:07:39.491876 stream is closed on send
05:07:39.491891 fail to send request via morpc stream: rpc stream closed
05:07:39.491937 reconnect signal is received
05:08:11.191982 forced subscribe table timeout
05:08:11.192082 开始下一轮 reconnect
05:08:11.218124 connected to server
即失效订阅等待约 31.7 秒后才进入下一次重连,下一次约 26 ms 恢复连接。代码中的 forcedSubscribeTable 在请求交给异步发送后等待订阅标记,按 30,000 个 1 ms tick 检查;该等待没有立即响应这里已发生的 stream 失败。期间事务准入暂停,30 秒客户端先超时。可核对 精确版本等待循环 和 重连流程。
Activity
[4.2-dev] Avoid SQL literal expansion for exact IVF PRE (#33551)
XuPeng-SH commentedon Dec 1, 2026
QA handoff for #33551 on
4.2-dev: tested the immediate pre-fix tree (34b63d72, build01514ba4) and final merge-equivalent tree (847e6c17, buildf1cdc4b5). The pre-fix shared build and fixed shared build both use-cover; source tree, binary version, and downloaded SHA-256 were checked.Independent Linux/amd64 single-CN MySQL TCP replay of the reported 8,300-row fixture: 1,021-byte VARCHAR keys, four IVF lists,
probe_limit=4; 16 alternating timed PRE/FORCE pairs per key count after two warmups. Every result wasseq=1..10.The same-tree pessimistic multi-CN BVT also ran
vector_ivf_pre_exact_domain.sql: 51 passed, zero skipped or failed, including a binary-key page with OFFSET, excluded closer rows, and an empty domain. This verifies the reported slowdown and those controls, not full scale/upgrade acceptance. QA should still challenge concurrent wide-key queries, cancellation, and byte-budget boundaries with larger persisted datasets. #33531 remains a separate issue.Ariznawlll commentedon Dec 1, 2026
结论
测试通过,限定为本 Issue 原始宽主键 IVF PRE 性能与正确性修复的验收。 补充测试发现的 TN 重启恢复超时已独立提交 #33654,不再将它混写为 #33551 性能修复失败。下文保留原始故障证据和拆分边界。
已查清此前两次冷重启查询超时所处的等待链:TN logtail 服务重建期间连接断开,CN 重连后仍等待系统表订阅完成,事务准入处于暂停状态。此次在最新 4.2-dev 上用真实 TN 重启再次得到同一等待栈,并保留现场确认能够随后恢复。恢复前的第一次 30 秒业务请求仍会失败,该故障恢复场景不通过,已由 #33654 独立跟踪。本 Issue 原始性能验收及对应 MOTR/CI 已完成,按原问题范围关闭;不表示该恢复缺陷已修复。
关键证据
版本、分支与环境
847e6c17c2a69ee5c3f1755ab2682806701e819f。6a905c7e660a71597ff1eb9fc61907145584377b,实际 SQLgit_version()核对完整 SHA;二进制 SHA256 为57ec42cbab0cee307ffdd7d1f7a7d82c5963e8c74e40705dd90fad55c2477cdb。没有用 main 替代 4.2-dev 验收。一、最新版本重做原始性能对照
严格使用原始 VARCHAR(1100)、实际 1021 字节主键、8300 行、IVF lists=4、probe_limit=4。保留同一 SQL 连接,8192/8193 两个候选域分别两轮预热、16 对交替 PRE/FORCE 查询,每次完整取数并核对
seq=1..10。对照为修复直接父提交
34b63d72614b81bf8fd4d08dd5930a0773342345;新/旧/旧/新四个独立环境依次执行,均核对运行版本和正常退出。以下为各单元 16 次中位数,ms:256 次计时查询全部结果正确。PRE 仍有约 8–10 倍改善;不把共享机器上的绝对毫秒数承诺为生产 SLA。此前
91c59a43bd519f7cccee408035cbf6c5b13dc0e2同样取得约 8–10 倍改善,此次表格是最新版本的新一组独立测量,没有混合旧样本。二、两次旧失败的现场证据
此前 portable-v2 与 portable-v4 在最后冷重启后报:
重新解压两轮当时保存的 CN goroutine 快照,两轮均有如下等待链,参数
(1,1)为系统库/系统表订阅:同时分别有 11 / 14 个 goroutine 停在
txnClient.waitReadyLocked;快照中没有 IVF 搜索执行栈。这与日志中 TN 副本替换、logtail 服务关闭/重建、CN stream closed 和事务暂停相吻合,不能仅凭最终错误码判断是向量算子慢。v4 原始 UTC 时间线:
此前清理过早结束了后续观察,因此旧两轮单独不能证明“永远恢复不了”,也不能证明数据丢失。
三、最新版本真实故障复现与恢复观察
保留已持久化的四张各 48,000 行表,在独立副本上执行:
wide的COUNT(*)=48000、SUM(seq)=1152024000。首组三轮中的第三轮得到:
对应 UTC 服务端日志:
即失效订阅等待约 31.7 秒后才进入下一次重连,下一次约 26 ms 恢复连接。代码中的
forcedSubscribeTable在请求交给异步发送后等待订阅标记,按 30,000 个 1 ms tick 检查;该等待没有立即响应这里已发生的 stream 失败。期间事务准入暂停,30 秒客户端先超时。可核对 精确版本等待循环 和 重连流程。随后用另一份独立数据副本再完成七轮同样 TN 重启,七轮首个读取均通过。合并计数为 10 轮中 1 轮首次超时、9 轮首次通过;所有轮次最终数据校验通过。这是本次观测频次,不作为概率保证。
这证明了可恢复的 CN logtail 重连等待及首次请求失败,不能写成 TN 永久退出或索引损坏。#29275 也涉及系统表订阅与事务暂停,但其大目录 forced-flush/取消条件不同,本次不直接判定二者重复。
四、已通过的扩展覆盖与 MOTR
0cbe63a8d3cb0c193e234de161922eb058d4c198。每套持久化用例增加至三次最终冷重启,并在冷读取失败时先保存等待栈和后续恢复情况,再保留失败退出;不会因后续读取恢复而把首个失败改成 PASS。main nullable check logic update for mergesort #404 只保留显式选择 4.2-dev 的每日薄调度。没有 MatrixOne 主库 PR。0cbe63a8d3cb0c193e234de161922eb058d4c198。15575456880):三套独立 wide-key fixture 全部通过,每套 5 次运行时版本检查均为6a905c7e660a71597ff1eb9fc61907145584377b;每套持久化后 72 项、取消后 72 项、三次最终冷重启各 72 项,共每套 360 项、三套 1,080 项矩阵断言。另有合计 30 次并发精确结果、30 次已观察到执行中的成功取消,以及 192 次计时查询的精确结果检查。待解决点
本 Issue 原始性能与正确性验收无剩余未通过项;以下故障恢复问题已移至 #33654,保留开放:
最终结论:本 Issue 原始性能问题测试通过,按原问题范围关闭。4.2-dev 宽主键 IVF PRE 性能、精确结果与对应 MOTR 回归/CI 均通过;TN 重启后首次业务请求超时仍未修复,已独立提交 #33654 跟踪。关闭 #33549 不代表 #33654 通过,也不代表所有故障恢复场景通过;MOTR 回归 PR 尚待合入。