Repository navigation
Description
Is there an existing issue for performance?
- I have checked the existing issues.
Searched fulltext/hybrid/redundant-work reports; no direct duplicate-MATCH-execution report found. #25132 concerns repeated SQL re-entry per widening round; this witness has one vector search round and duplicate fulltext branches inside that round. #30164 tracks unnecessary relevance sorting separately.
Environment
- Version or commit-id: main,
8586fa08715c868cab997d11d2687a76b8cc360f(actual tested binary; not a claim about today's main). - Hardware parameters: CPU-only local test; GOMAXPROCS=4, GOMEMLIMIT=6GiB. Physical CPU model was not recorded.
- OS type: Linux amd64; Go1.27.1, GOAMD64=v3, GOEXPERIMENT=simd.
- Others: 1 LogService / 1 TN / 1 CN; mysql-connector-python, use_pure=True, autocommit=True. Independent synthetic fixtures, no production source edits.
Details of Performance
IVFFLAT PRE filtering combined with MATCH executes the same fulltext hit production separately for its membership side and its final-result side.
In an actual single-list, single-probe test with 1026 rows and 16 rare-word hits, EXPLAIN ANALYZE shows two Fulltext Index Scan instances for ix_ft. Both consume/output 16 hits; both matching base-table scans consume/output 16 rows. The membership branch additionally relevance-sorts all 16 hits. The final vector Top returns IDs 1010..1016 correctly.
Vector execution reports one search, one round, 16 vectors scored. Background Queries reports four rounds, consistent with duplicated fulltext metadata/token work. This report does not equate every background round with a vector round or infer a fixed latency multiplier.
Fixture / reproduction
The SQL generator below expresses the executed insertion loop's same rows. It has not been independently rerun on today's main.
CREATE DATABASE hybrid_repro;
USE hybrid_repro;
SET experimental_fulltext_index=1;
SET experimental_ivf_index=1;
SET experimental_hnsw_index=1;
CREATE TABLE docs(
id BIGINT PRIMARY KEY,body TEXT,tag INT,v VECF32(2) NOT NULL
);
INSERT INTO docs
SELECT result,
CASE WHEN result=1026 THEN NULL
WHEN result>1009 THEN 'needle omega'
WHEN result%3=0 THEN 'alpha beta'
ELSE 'alpha plain' END,
CASE WHEN result=1026 OR result%17=0 THEN NULL ELSE result%7 END,
CONCAT('[',result,',0]')
FROM generate_series(1,1026,1) g;
CREATE FULLTEXT INDEX ix_ft ON docs(body);
SET probe_limit=1;
CREATE INDEX ix_v USING ivfflat ON docs(v)
LISTS=1 OP_TYPE 'vector_l2_ops';
SELECT mo_ctl('dn','flush','hybrid_repro.docs');
EXPLAIN ANALYZE
SELECT id FROM docs
WHERE MATCH(body) AGAINST('needle')
ORDER BY l2_distance(v,'[0,0]')
LIMIT 7 BY RANK WITH OPTION 'mode=pre';Observed shape:
Top(distance, LIMIT 7)
result Join
Join(base, Fulltext Index Scan ix_ft) FT input/output=16/16
membership SEMI Join
Vector Index Scan ix_v vectors scored=16
relevance Sort
Join(base, Fulltext Index Scan ix_ft) FT input/output=16/16
Desired performance: when both consumers require the same MATCH set at the same snapshot, avoid repeating its index search and base fetch solely because the vector PRE rewrite generated two branches. Share or otherwise safely reuse the proven common hit set. Preserve valid matches and exact final distance order.
Additional information
Whitebox context: the shared search design describes early vector rewrite followed by late fulltext rewrite. The analyzed PRE topology contains a membership subtree and a result subtree that each receive the same MATCH rewrite. This identifies the common-work opportunity; a complete source-level causal trace or sharing patch was not implemented.
Any reuse must prove equal index/query/mode/score-range/tenant/snapshot semantics and retain independent consumer lifetimes, cancellation, late errors and cleanup. Avoid unbounded whole-hit-set materialization; preserve streaming and memory accounting. Benchmark rare and common terms, small/large eligible sets, prepared term changes, zero/positive LIMIT, selective scalar predicates and multi-consumer cancellation. DML/DDL/snapshot changes must not reuse a stale set.
Retained receipt: hybrid-results.jsonl, hybrid/ft_ivf/needle/all/pre/analyze. Current results are correct; this is an efficiency finding. No GPU, multi-CN, cold-cache or production throughput validation is claimed. The broader candidate-completion feature #28988 is not a substitute for this duplicate-work issue.
Activity
perf(plan): avoid duplicate MATCH searches in IVFFLAT PRE (#30178)
slyunnn commentedon Oct 21, 2026
Regression and extended verification for #30165 (2026-10-21)
Verification Environment
origin/main:40300d10e5b67dfc166c0646dbe4262fcca585a0,fix(vectorindex): isolate AVX-512 kernels from CPU dispatch (#30630).make build TYPECHECK=1; the running binary reports40300d10e5, Go1.27.1, Linux/arm64, CPU-only.2 CN / 1 TN / 1 Log service / 1 Proxy, using local shared-disk storage. Proxy127.0.0.1:6001, CN1127.0.0.1:16001, and CN2127.0.0.1:16002were individually connected and used for the original query and extended verification.database/sqlwithgo-sql-driver/mysql,interpolateParams=false, including realCOM_STMT_PREPARE/COM_STMT_EXECUTEon a pinned connection.What Was Covered
1,026-row fixture,LISTS=1,probe_limit=1, flush, andLIMIT 7 BY RANK WITH OPTION 'mode=pre': each endpoint returned IDs1010through1016.EXPLAIN ANALYZEshowed exactly1Fulltext Index Scan,1vector search round, and16vectors scored.NULLfilters; score thresholds; Boolean search; mixed predicates; separate search terms; projected body;LIMIT 0; and offset pagination.fulltextandfulltext2compatibility, compared with identical fulltext-only reference tables for exact PRE rows, order, and projected scores. Score comparisons use tolerance1e-5.2required fulltext producers; separate terms retained their distinct searches. POST mode was checked as an ordered subset rather than incorrectly requiring PRE completion.UPDATE,DELETE, andINSERT.FULLTEXT2 FORCE_SYNCestablished the indexed state before the post-DML check; independent expected IDs were1012through1018.LIMITwas rejected with1149; the same connection remained usable. Test databases were removed.40/40checks per endpoint,120/120overall. Isolated endpoint databases ran concurrently. MOTR SQL and protocol cases also passed with-j 2; this describes test scheduling, not an engine-parallel performance claim.Findings
43ae1edafafa5749315d567a3f18a38ff53d3eaa,perf(plan): avoid duplicate MATCH searches in IVFFLAT PRE.MOTR / BVT Coverage
test/issue-30165-ivf-pre-single-match; source commitbb2ad95a61448ba7e932be1daceb970cfb560236, pushed tomatrixorigin/motrand verified remotely.suites/14_issue_regression/{t,r}/issue_30165_ivf_pre_single_match.{test,result}; companion Go protocol test and launcher underscript/14_issue_regression/.19/19statements; normal replay passed twice. Final SQL/protocol parallel replay passed2/2cases, also after the daily cherry-pick.d5957c21fbe8169be4613e80ee10e80eff5b8ff9. No MatrixOne service source changed.Final Conclusion
Fixedfor the filter-only duplicate MATCH execution reported in #30165 on the tested main commit.Additional large-data regression is not required for this bounded planner optimization: the original
1,026-row fixture exercises the real IVFFLAT PRE path and directly asserts producer cardinality. Larger datasets would increase cost without proving a new execution boundary; production performance benchmarking remains separate.