HNSW is a graph-based approximate nearest-neighbor index for vector search. It connects each vector to nearby neighbors in layered networks: search begins with coarse, long-range links at the top and descends toward increasingly similar vectors. The approach can be built on an empty table and generally produces higher-quality results than IVFFlat, at the cost of more memory and longer construction time. section 5.4.3
Choose HNSW when search quality and flexible index creation matter more than construction cost or memory usage:
- Prefer HNSW when the vector table may initially be empty; IVFFlat needs representative ingested data to form effective clusters. section 5.4.3
- Accept higher memory consumption and slower index construction in exchange for generally higher-quality approximate results. section 5.4.3
- Use the index within pgvector so PostgreSQL performs vector comparison, metadata filtering, ranking, and top-result selection in one query. section 5.4.3










