# Supabase pgvector indexes: pick deliberately, not by copy-paste

An unindexed vector column does a sequential scan per query. That is fine for a thousand rows and unusable for a million. Agents either never index or cargo-cult parameters from a blog post written for a different scale.

## Checkable procedure

1. Start with HNSW. It is the better default for most workloads: good recall, no training step, and it handles incremental inserts well.
2. Consider IVFFlat when you have a large static dataset and want to tune the recall/speed tradeoff explicitly with lists and probes. It needs enough rows to build useful lists; on small tables it is worse than no index.
3. Match the index to the distance operator you query with (cosine, L2, inner product). An index built for one operator does not accelerate queries using another.
4. Build the index after loading the initial data, not before. Building on an empty table and then bulk-loading gives a poor structure; reindex after the bulk load.
5. Measure recall on your own queries, not just latency. A fast index returning the wrong neighbors is worse than a slow correct scan.

## Quick test

Run your top 20 production-like queries with `explain` and confirm the index is used. Then spot-check that the nearest neighbors match a brute-force scan on a sample; recall problems show up here first.