← Back to all projects

pgvector

Vector search as a Postgres extension, so embeddings live in the database the rest of the data lives in

OfficialPostgreSQL License
Stars
23.5k
Forks
1.4k
Open issues
15
Last commit
28 Oct 2026

What is pgvector?

A vector becomes a column type, and from there everything Postgres already does applies: a nearest-neighbour query is an ORDER BY with a LIMIT, filters are WHERE clauses evaluated by the same planner, the embedding and the row it describes are written in one transaction, and the backups, replicas and roles you already run cover the vectors too. What you give up is the operational apparatus a dedicated engine provides — sharding a collection, isolating tenants — and the fact that index builds now compete with the rest of the workload for the same machine.

What can you do with pgvector?

  • Filter and join like it is ordinary data — Because the vector is a column, a WHERE clause, a join to another table and an aggregate all work as usual, and the embedding is committed in the same transaction as the record it belongs to.
  • Pick the index for the trade you want — HNSW gives the better speed-versus-recall result but builds more slowly and holds more memory; IVFFlat builds faster and lighter but searches less well and has to be created after the data exists so it can train on it.
  • Shrink vectors when full precision is not the constraint — Half-precision vectors halve the bytes per element, binary vectors support Hamming and Jaccard distance, and a sparse type stores sparse embeddings compactly — all up to sixteen thousand dimensions.
  • Six distance metrics as operators — L2, inner product, cosine, L1, Hamming and Jaccard are available as operators, so the choice of metric is part of the query rather than a property fixed when the store was created.
  • Inherit the operations you already have — ACID guarantees, existing dump and restore procedures, replication and role-based access all cover the vector data, so there is no second system to secure, monitor and back up separately.

Before you choose pgvector

  • The vectors share one instance with everything else, so building an index and running searches compete with the transactional workload for the same memory and CPU rather than being isolated from it.
  • Features a dedicated vector engine treats as built-in — sharding a collection across nodes, per-tenant isolation — are Postgres's problem here, addressed with Postgres's own tooling or not at all.

Star history

21 Aug to 30 Oct · +844

22.7k23.5k

Frequently asked questions

Is pgvector free for commercial use?

pgvector is released under the PostgreSQL License licence — OSI-approved open source, which permits commercial use.

How can pgvector be deployed?

pgvector is available as Self-hosted / Runs locally.