pgvector/pgvector

Open-source vector similarity search for Postgres

What it solves

pgvector is an open-source extension for PostgreSQL that allows you to store and search vector embeddings directly within your database. This eliminates the need for a separate specialized vector database by allowing you to keep your embeddings alongside your relational data, while maintaining ACID compliance and supporting standard SQL queries.

How it works

It introduces a vector data type and specialized distance operators to perform similarity searches. It supports multiple vector formats including single-precision, half-precision (halfvec), binary (bit), and sparse vectors (sparsevec).

To speed up searches, it provides two types of approximate nearest neighbor (ANN) indexes:

  • HNSW (Hierarchical Navigable Small World): A multilayer graph index that offers high query performance and better speed-recall tradeoffs, though it requires more memory and slower build times.
  • IVFFlat: A list-based index that divides vectors into clusters, offering faster build times and less memory usage than HNSW.

Who it’s for

Developers and data engineers who already use PostgreSQL and want to integrate vector similarity search for AI applications (like RAG or recommendation systems) without adding new infrastructure to their stack.

Highlights

  • Postgres Integration: Leverages ACID compliance, JOINs, and point-in-time recovery.
  • Versatile Distance Metrics: Supports L2, inner product, cosine, L1, Hamming, and Jaccard distances.
  • Flexible Vector Types: Handles dense, half-precision, binary, and sparse vectors.
  • Hybrid Search: Can be combined with Postgres full-text search for combined keyword and semantic search.
  • Scalability Tools: Includes binary quantization and iterative index scans to improve recall when filtering data.

Related

  • Project
  • Project
  • Project
  • Project
  • Project