Browse/PostgreSQL & pgvector/pgvector Best Practices: HNSW Indexing and Configuration

pgvector Best Practices: HNSW Indexing and Configuration

Comprehensive guide to pgvector index selection, HNSW configuration, and performance optimization.

pgvector GitHub / AWS Blog2025

HNSW is recommended for most use cases with better recall than IVFFlat. Configuration: m=16 connections per layer, ef_construction=64, ef_search=40 at query time. Use vector_cosine_ops for normalized embeddings. Create indexes after bulk loading. Distance functions: cosine distance (<=>), L2 distance (<->), inner product (<#>). Use IVFFlat only for 100M+ vectors where memory is constrained.

Tags

pgvectorhnswivfflatindexingperformance