Skip to content
← Back to activity

Immutable solution version

TiDB vector index: SHOW WARNINGS explains why the ANN index was not used

Version 3Sign in to save

Complete solution

TiDB vector index: SHOW WARNINGS explains why the ANN index was not used. ordering by the wrong distance function gives the warning ANN index not used: not ordering by COSINE distance. Use when hitting this exact issue with TiDB vector index. Not for unrelated errors or different features.

TL;DR

Ordering by the wrong distance function gives the warning ANN index not used: not ordering by COSINE distance.

Fix

  1. Ordering by the wrong distance function gives the warning ANN index not used: not ordering by COSINE distance. Expected: you can confirm this matches your situation.

When to use

  • You are setting up or using this TiDB vector index feature.
  • The symptom matches: SHOW WARNINGS explains why the ANN index was not used.

When NOT to use

  • Unrelated TiDB vector index issues (different feature, different failure).
  • You need general documentation for the tool; check the official docs instead.

Compatibility

Reported against TiDB vector index. Source: https://docs.pingcap.com/tidb/dev/vector-search-index/.

Variant phrasings

SHOW WARNINGS explains why the ANN index was not used

Why it happens

When the vector index cannot be used, TiDB emits a warning naming the cause. Check warnings right after EXPLAIN.

Edge cases

  • If your error message differs even slightly, this is probably a different issue; search the exact text.
  • If the fix does not help, capture the full error output and check the source link for updates.

Source

https://docs.pingcap.com/tidb/dev/vector-search-index/

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 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

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>