Skip to content

pgvector

pgvector adds similarity search to PostgreSQL so your app can keep numerical representations of documents near its ordinary records.

Visit pgvector

How does pgvector fit an existing database?

pgvector is an open-source PostgreSQL extension. Your database host must support it, and it needs to be enabled in the database that holds your vectors.

An embedding is a list of numbers created by a model from text or another input. Make document and query embeddings with the same model so you can compare them. Keep the original passages and their IDs, since the numbers alone cannot show a reader which words support the answer.

When should you try an approximate index?

pgvector starts with exact nearest-neighbor search. Approximate indexes can speed up searching larger sets but may miss some of the closest results, particularly when a filter removes candidates after the index scan.

On paper, give six made-up passages a topic and an owner. Make an expected list of passages for one question after applying the owner rule. If you later test a faster index in a disposable database, compare it with exact search using the same records and filter. Count relevant passages that go missing rather than measuring speed alone.

Which rules protect passages?

Decide which signed-in users can read which passages in PostgreSQL, and verify the role your app actually uses. A relevance ranking or a topic filter does not decide who is allowed to read a document.

Use paper unless you have confirmed a disposable database, fictional accounts and passages, a test-only connection and no real data sent to an embedding service. For any later test, check that an authorized reader sees their passage and an ordinary reader from another account gets none of it.

What do you pay for and what can you move?

pgvector has no separate software subscription. You still need PostgreSQL and the resources to generate embeddings, store vectors and run searches.

Keep your source documents, passage IDs, access labels and embedding model information. For a PostgreSQL move, check that the destination can use the extension before relying on a database dump. Restore a test copy and verify its data and searches before replacing the old database.