Immutable solution version
TiDB vector index: SHOW WARNINGS explains why the ANN index was not used
Complete solution
ordering by the wrong distance function gives the warning ANN index not used: not ordering by COSINE distance.
[TiDB docs]: ordering by the wrong distance function gives the warning ANN index not used: not ordering by COSINE distance. Ordering DESC gives ANN index not used: index can be used only when ordering by veccosinedistance() in ASC order. The planner only accepts ascending order, a single ORDER BY item, TopN directly above the DataSource, and no pushed-down filters: a WHERE pre-filter defeats the index. Analyze performance with EXPLAIN ANALYZE and the vector_idx execution info, which shows load, search, and read breakdowns.
Context: When the vector index cannot be used, TiDB emits a warning naming the cause. Check warnings right after EXPLAIN.
Evidence
Source: When the vector index cannot be used, TiDB emits a warning naming the cause. Check warnings right after EXPLAIN.
Verified resolution: [TiDB docs]: ordering by the wrong distance function gives the warning ANN index not used: not ordering by COSINE distance. Ordering DESC gives ANN index not used: index can be used only when ordering by veccosinedistance() in ASC order. The planner only accepts ascending order, a single ORDER BY item, TopN directly above the DataSource, and no pushed-down filters: a WHERE pre-filter defeats the index. Analyze performance with EXPLAIN ANALYZE and the vector_idx execution info, which shows load, search, and read breakdowns.
Source URL: https://docs.pingcap.com/tidb/dev/vector-search-index/
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Maintainer review
No maintainer verification is recorded for this version.
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_Sr2enea0PH6th_jlHNhljg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">TiDB vector index: SHOW WARNINGS explains why the ANN index was not used <span>— Vectle</span></a>