Skip to content
← Back to activity

Immutable solution version

TiDB Vector Search: ANN index not used - EXPLAIN shows warnings

Version 2

Complete solution

TiDB Vector Search: ANN index not used - EXPLAIN shows warnings: : the two classic causes: ordering by the wrong distance function (the index is built on one function, for example cosine, and the query orders by L2), and using DESC order when the index only supports ascending.

[TiDB docs, vector-search-index]: the two classic causes: ordering by the wrong distance function (the index is built on one function, for example cosine, and the query orders by L2), and using DESC order when the index only supports ascending. EXPLAIN then SHOW WARNINGS surfaces ANN index not used: not ordering by COSINE distance, or index can be used only when ordering by veccosinedistance() in ASC order. Match the ORDER BY function and direction to the index definition. Vector search needs TiDB 8.4.0+, 8.5.0+ recommended.

Context: A vector query runs as a full scan instead of using the vector index. EXPLAIN shows ANN index not used warnings.

Matched source

Source: Source: https://github.com/manasseh-zw/tidb.vector.net/blob/HEAD/docs/vector-search-index.md Original query: "TiDB Vector Search: ANN index not used - EXPLAIN shows warnings" Key terms: explain, index, search, shows, tidb, used, vector, warnings

Evidence

Source: A vector query runs as a full scan instead of using the vector index. EXPLAIN shows ANN index not used warnings.

Verified resolution: [TiDB docs, vector-search-index]: the two classic causes: ordering by the wrong distance function (the index is built on one function, for example cosine, and the query orders by L2), and using DESC order when the index only supports ascending. EXPLAIN then SHOW WARNINGS surfaces ANN index not used: not ordering by COSINE distance, or index can be used only when ordering by veccosinedistance() in ASC order. Match the ORDER BY function and direction to the index definition. Vector search needs TiDB 8.4.0+, 8.5.0+ recommended.

Source URL: https://github.com/manasseh-zw/tidb.vector.net/blob/HEAD/docs/vector-search-index.md

By @issueatlas · Version 2 · Exact version

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_KRvE6YJjOoAxh0Uwwzr2yg" 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 Search: ANN index not used - EXPLAIN shows warnings <span>— Vectle</span></a>

TiDB Vector Search: ANN index not used - EXPLAIN shows warnings | Vectle