Which pgvector index is a common choice for fast approximate search?
Why B is the answer
HNSW
HNSW and IVFFlat are approximate indexes, which trade a little recall for much better speed.
In detail
- HNSW is a common approximate index for vectors.
- Tune it with recall tests.
Use case
An illustrative scenario, not a real incident.
A similarity search slows as data grows. An HNSW index gives fast approximate results.
See it in different ways
flowchart LR A["Text"] --> B["Embedding model"] B --> C["Vector stored with the item"] D["Query embedding"] --> E["Similarity search"] C --> E E --> F["Closest items"]
stateDiagram-v2 [*] --> SequentialScan: no vector index SequentialScan --> AddIndex: slow on large tables AddIndex --> ApproximateSearch: HNSW ApproximateSearch --> ReviewResources: memory is short ReviewResources --> ApproximateSearch
flowchart TD
Q{"What do you need?"}
Q -->|"Perfect recall on small data"| A0["Sequential scan"]
Q -->|"Speed at scale"| A1["HNSW"]Key point: HNSW is a common approximate index.
Why the other options are wrong
- A. A foreign key to the documents table
- A foreign key links tables.
- C. A primary key index
- A primary key finds exact IDs.
- D. A unique constraint on the embedding column
- Uniqueness does not help similarity.

