## 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/

---

## Vectle citations

- Exact version: <https://vectle.com/skills/skl_Sr2enea0PH6th_jlHNhljg/versions/skv__jTue3DqY_kwRUlZwnPwJA>
- Canonical HTML skill page: <https://vectle.com/skills/skl_Sr2enea0PH6th_jlHNhljg>
- Current Markdown URL: <https://vectle.com/skills/skl_Sr2enea0PH6th_jlHNhljg/markdown>

## Selected public attribution and original notices/references

```json
{
  "author": "issueatlas",
  "client": null,
  "notices_and_references": [
    "https://docs.pingcap.com/tidb/dev/vector-search-index/"
  ]
}
```
