Devii · Data & analytics · 2026-06-04 · 8 min read
pgvector: Vector Similarity Search Inside PostgreSQL
Store embeddings in Postgres, index with IVFFlat or HNSW, and query with distance operators.
**pgvector** is an open-source PostgreSQL extension adding the `vector` type and similarity operators (`<->`, `<#>`, `<=>`). It lets teams colocate embeddings with relational data instead of operating a separate vector database for many workloads.
Create indexes with **IVFFlat** or **HNSW** (availability depends on pgvector version) to accelerate nearest-neighbor queries. Index build time and recall trade off with list counts and ef_search parameters documented in the extension README.
Typical pattern: generate embeddings via your model API, store rows with metadata foreign keys, filter with SQL `WHERE` clauses, then order by distance. Hybrid search combines full-text `tsvector` with vectors for better recall.
Read `github.com/pgvector/pgvector` and PostgreSQL docs for your server version. Reindex when embedding model dimensions change.