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
[Refactoring]: replace TVF with better plan #26977
Overall, seems using an TVF is really not a good idea. We should replace the TVF with really a plan and splice the plan with the whole query plan, so that optimization can correctly, efficiently, optimize whole query -- right now the TVF is a separate pass and cross boundary, causing many troubles.
Describe the solution you'd like
splice the plan with the whole query plan, so that optimization can correctly, efficiently, optimize whole query -- right now the TVF is a separate pass and cross boundary, causing many troubles.
Regression and extended verification for #26977 (2026-09-01)
Verification Environment
Source: latest origin/main at 33af6ae3c0c23e4f277137460577ea64678f7ecf — perf(plan): avoid wide HashBuild for full indexed UPDATE (#27920).
Related fix: 5735684d69c9b171c4d7a5ebee3ebcc539ffc8cc — refactor: replace IVF search TVF with vector index scan (#27297). The merge commit is an ancestor of the tested origin/main.
Topology: isolated Linux Docker runtime built from that exact source checkout, with 1 Log + 1 TN + 2 CN + 1 Proxy in the same container.
Test endpoints: Proxy 127.0.0.1:18000, CN1 127.0.0.1:18001, and CN2 127.0.0.1:18002; all completed MySQL initial handshake and a post-test SELECT 1.
Client protocol: MySQL wire protocol over TCP, using the mysql client.
What Was Covered
OK — Prepared IVF query reuse through the Proxy: EXECUTE with k = 2 then k = 3 selected Vector Index Scan and returned the changed result cardinality.
OK — Correlated CROSS APPLY with an INCLUDE(category) pre-filter: two prepared executions rebound concat(?, '') from x to y, returned different expected ids, and retained Vector Index Scan.
OK — Historical account snapshot: the snapshot query selected Vector Index Scan and returned the snapshot-visible row rather than the post-snapshot nearest row.
OK — Multi-CN execution through the Proxy: EXPLAIN and EXPLAIN ANALYZE reported AP QUERY PLAN ON MULTICN and Vector Index Scan; integer, string, composite, and sparse-id results matched their exact-result controls.
OK — Direct CN coverage: CN1 replayed the IVF l1_distance and l2_distance_sq cases; CN2 replayed the vector op_type matrix, including l2_distance, l2_distance_sq, l1_distance, inner_product, and cosine_distance controls.
OK — Unhappy paths: expected ERROR 20301 dimension mismatch and invalid op_type diagnostics were returned; the BVT continued and subsequent valid cases passed.
OK — INCLUDE mode controls: include, post, and pre plans each selected the intended access path and returned the same filtered top-3 rows.
OK — Focused current-main unit checks for immutable prepared generations, APPLY transaction offsets, pre-filter rebinding, reader cleanup, snapshot/publisher identity, non-historical snapshots, MaxUint64, filtering-before-Top-K, planner rewrite, pagination, and catalog dependencies.
OK — Bounded scale regression: a 16,384-row IVF table on the multi-CN Proxy path returned 20 rows with Vector Index Scan and an index primary-key filter.
Not covered — The full 407/407 vector BVT aggregate job and race suite were not rerun in this local session; their exact-head results are recorded in the merged PR.
Findings
The ivf_search TVF replacement is operational on latest origin/main: optimizer-visible VECTOR_INDEX_SCAN appears in the public plan, survives prepared-plan reuse and correlated APPLY, and preserves snapshot, account, filter, pagination, and multi-CN behavior.
Focused product BVT SQL files were replayed through the MySQL client: vector_prepared_limit.sql, vector_ivf_snapshot.sql, vector_ivf_multicn_search.sql, vector_ivf_l1_l2sq.sql, vector_index_optype_matrix.sql, and vector_ivfflat_include_mode_comparison.sql. Expected-error statements were continued deliberately; no unexpected SQL failure occurred. Test databases were absent after cleanup.
MOTR / BVT Coverage
No MOTR change is needed for this refactoring. The related fix already introduced/updated the owning product vector BVT coverage. This verification directly replayed the focused SQL files, but did not invoke the full mo-tester aggregate runner; therefore the aggregate 407/407 result is not claimed as a new local run.
Large-data regression was required in bounded form because candidate scanning and Top-K execution can depend on row/batch boundaries. The 16,384-row multi-CN case was used as the minimum stable scale check and crossed a non-trivial scan boundary. A larger memory/spill or throughput campaign is not needed for this conclusion: no issue-specific failure depends on resource exhaustion, data skew, network transfer, or a configured spill threshold.
Final Conclusion
Fixed. Latest origin/main contains the linked refactor and passed direct product SQL, focused unit, multi-CN, Proxy, prepared, APPLY, snapshot, unhappy-path, operator-control, and bounded-scale verification. No MatrixOne source or MOTR test was modified in this verification.
Activity
cpegeric commentedon Aug 12, 2026
For thie refactoring, I don't know much about the plan. You'd better discuss with Feng who is the best person to change the Plan.
slyunnn commentedon Sep 1, 2026
Regression and extended verification for #26977 (2026-09-01)
Verification Environment
origin/mainat33af6ae3c0c23e4f277137460577ea64678f7ecf—perf(plan): avoid wide HashBuild for full indexed UPDATE (#27920).5735684d69c9b171c4d7a5ebee3ebcc539ffc8cc—refactor: replace IVF search TVF with vector index scan (#27297). The merge commit is an ancestor of the testedorigin/main.1 Log + 1 TN + 2 CN + 1 Proxyin the same container.127.0.0.1:18000, CN1127.0.0.1:18001, and CN2127.0.0.1:18002; all completed MySQL initial handshake and a post-testSELECT 1.mysqlclient.What Was Covered
EXECUTEwithk = 2thenk = 3selectedVector Index Scanand returned the changed result cardinality.CROSS APPLYwith anINCLUDE(category)pre-filter: two prepared executions reboundconcat(?, '')fromxtoy, returned different expected ids, and retainedVector Index Scan.Vector Index Scanand returned the snapshot-visible row rather than the post-snapshot nearest row.EXPLAINandEXPLAIN ANALYZEreportedAP QUERY PLAN ON MULTICNandVector Index Scan; integer, string, composite, and sparse-id results matched their exact-result controls.l1_distanceandl2_distance_sqcases; CN2 replayed the vectorop_typematrix, includingl2_distance,l2_distance_sq,l1_distance,inner_product, andcosine_distancecontrols.ERROR 20301dimension mismatch and invalidop_typediagnostics were returned; the BVT continued and subsequent valid cases passed.INCLUDEmode controls:include,post, andpreplans each selected the intended access path and returned the same filtered top-3rows.APPLYtransaction offsets, pre-filter rebinding, reader cleanup, snapshot/publisher identity, non-historical snapshots,MaxUint64, filtering-before-Top-K, planner rewrite, pagination, and catalog dependencies.16,384-row IVF table on the multi-CN Proxy path returned20rows withVector Index Scanand an index primary-key filter.407/407vector BVT aggregate job and race suite were not rerun in this local session; their exact-head results are recorded in the merged PR.Findings
The
ivf_searchTVF replacement is operational on latestorigin/main: optimizer-visibleVECTOR_INDEX_SCANappears in the public plan, survives prepared-plan reuse and correlatedAPPLY, and preserves snapshot, account, filter, pagination, and multi-CN behavior.Focused product BVT SQL files were replayed through the MySQL client:
vector_prepared_limit.sql,vector_ivf_snapshot.sql,vector_ivf_multicn_search.sql,vector_ivf_l1_l2sq.sql,vector_index_optype_matrix.sql, andvector_ivfflat_include_mode_comparison.sql. Expected-error statements were continued deliberately; no unexpected SQL failure occurred. Test databases were absent after cleanup.MOTR / BVT Coverage
No MOTR change is needed for this refactoring. The related fix already introduced/updated the owning product vector BVT coverage. This verification directly replayed the focused SQL files, but did not invoke the full
mo-testeraggregate runner; therefore the aggregate407/407result is not claimed as a new local run.Large-data regression was required in bounded form because candidate scanning and Top-K execution can depend on row/batch boundaries. The
16,384-row multi-CN case was used as the minimum stable scale check and crossed a non-trivial scan boundary. A larger memory/spill or throughput campaign is not needed for this conclusion: no issue-specific failure depends on resource exhaustion, data skew, network transfer, or a configured spill threshold.Final Conclusion
Fixed. Latest
origin/maincontains the linked refactor and passed direct product SQL, focused unit, multi-CN, Proxy, prepared,APPLY, snapshot, unhappy-path, operator-control, and bounded-scale verification. No MatrixOne source or MOTR test was modified in this verification.