Favicon of pgvector

pgvector

A Postgres extension that stores and searches vectors alongside application data, with exact search and optional HNSW or IVFFlat indexes.

pgvector adds vector similarity search to Postgres for developers building applications that need to find related items. It keeps embeddings alongside application records, so vector searches can use the same database as the rest of your data.

  • SQL integration: Combine similarity searches with relational filters and joins, using any language that has a Postgres client.
  • Exact or approximate search: Exact nearest neighbor search is the default; optional HNSW and IVFFlat indexes trade some recall for faster queries.
  • Vector types and distances: Store single-precision, half-precision, binary or sparse vectors and compare them using cosine distance, inner product, L2 or L1, with Hamming and Jaccard distances for binary vectors.
  • Smaller indexes: Half-precision indexing and binary quantization reduce index size, and indexes don't have to fit entirely in memory.
  • Database recovery: Vector data uses Postgres transactions and write-ahead logging, including support for replication and point-in-time recovery.

You can use pgvector in a Postgres database on your own server. HNSW offers a better query speed and recall tradeoff than IVFFlat, but takes longer to build and consumes more memory. IVFFlat builds faster and uses less memory. Approximate searches can return fewer matches when filters narrow the results; iterative index scans can search further to address this.

Similar to pgvector