Vector database

A vector database,

built into Postgres.

Store embeddings, search by meaning, and power RAG with pgvector, the open-source vector extension for PostgreSQL. Run it on a managed Postgres instance or inside a project, with the same backups, pooling, and scaling as the rest of your data. No separate vector database to run, sync, or pay for.

pgvector extension /Embeddings & similarity search /Managed Postgres or in a Project /From $5/mo

The basics

What is a vector database?

A vector database stores data as vectors, lists of numbers called embeddings that capture the meaning of text, images, audio, or code. Instead of matching exact keywords, it finds the items whose vectors sit closest to your query, so you can search by meaning and similarity rather than literal words.

Traditional databases are great at exact matches: find the row where the email equals this, or the orders placed after that date. They struggle with a fuzzier question, the one most AI features ask: "what is most similar to this?"

A vector database answers that. You convert your content into embeddings with a model, store those embeddings, and then look up the nearest ones to a new query. Because similar meanings produce nearby vectors, the closest matches are the most relevant, which is exactly what semantic search, recommendations, and RAG need.

The catch is that most teams already keep their real data, users, documents, orders, in PostgreSQL. With pgvector, you do not need a second database for the vectors. Postgres becomes your vector database too.

How it works

How vector databases work,
in four steps.

01
Turn data into embeddings

An embedding model turns text, images, audio, or code into a vector, a long list of numbers that captures meaning. Things that mean similar things end up with similar vectors.

02
Store the vectors

pgvector adds a native vector column to PostgreSQL, so embeddings live in the same table as the rest of your data. There is no separate store to keep in sync.

03
Index for speed

Build an HNSW or IVFFlat index so similarity search stays fast as your data grows, from a few thousand vectors into the millions.

04
Query by similarity

Ask for the nearest neighbours to a query vector using cosine, L2, or inner-product distance. You get back the closest matches, ranked by meaning instead of keywords.

What people build

What you would use
a vector database for.

Semantic search

Search by intent, not exact words. Return results that mean the same thing, even when the phrasing is completely different.

RAG and AI chat

Ground a language model in your own content. Retrieve the most relevant chunks and pass them to the model as context.

Recommendations

Surface similar products, articles, or tracks by comparing embeddings, instead of maintaining brittle hand-written rules.

Image and audio search

Find visually or sonically similar media by embedding the file and looking up its nearest neighbours.

Deduplication

Catch near-duplicate records and content by how close their vectors sit, not by exact string matching.

Anomaly detection

Flag outliers whose embeddings sit far from everything else, handy for fraud, moderation, and quality checks.

One database, not two

You probably do not need
a separate vector database.

Standalone vector databases mean a second system to provision, secure, scale, and keep in sync with your source of truth. For most products that is more moving parts than the problem deserves.

With pgvector, your embeddings live next to the rows they describe. You can filter by a real column and rank by similarity in the same query, wrap writes in a transaction, and trust one backup to cover all of it.

  • Vectors and rows in one place, joined in plain SQL
  • Real transactions, so embeddings never drift from your data
  • One thing to back up, scale, and pay for
Filter and rank, in one query
-- nearest documents to a query embedding,
-- for one workspace, newest first on ties
SELECT id, title
FROM documents
WHERE workspace_id = $1
ORDER BY embedding <=> $2
LIMIT 5;

The <=> operator is cosine distance. Swap in <-> for L2 or <#> for inner product.

Vector search on Selfhost.dev

A production vector database.
Without the extra database.

One click to enable

Choose Vector Database when you create a Postgres instance, or turn pgvector on in a project database. We run CREATE EXTENSION and tune memory for vector workloads.

Vectors next to your data

Keep embeddings in the same database as your users, orders, and documents. Join them in plain SQL, inside real transactions.

Open source, no lock-in

pgvector is open source and standard PostgreSQL. Your data and queries stay portable, with no proprietary vector API to get stuck behind.

PITR on your vectors

Point-in-time recovery, automated backups, encryption at rest, and forking cover your embeddings exactly like the rest of your Postgres data.

Pooling and scaling

PgBouncer pooling, resizing, and Multi-AZ are all included, so vector workloads get the same production treatment as everything else.

Drive it with AI

Create the database, enable pgvector, and inspect performance from Claude, Cursor, or any MCP client with 150+ MCP tools.

Create a vector database

How to choose

pgvector, or a dedicated
vector database?

Pinecone, Weaviate, Milvus, Qdrant, and Chroma are purpose-built vector databases. They are excellent, and they are also a second system. Here is an honest way to decide.

Postgres + pgvector

Choose this when

  • You already use Postgres and want one database, not two
  • You need transactional consistency between vectors and your rows
  • You are doing semantic search or RAG into the millions of vectors
  • You want SQL joins, filters, and real backups on your embeddings
  • You would rather not run, sync, and pay for a separate system
A dedicated vector DB

Consider one when

  • You are storing hundreds of millions or billions of vectors
  • You need extreme query throughput as a dedicated workload
  • Vector search is your entire product, with no relational data

Even then, many teams start on pgvector and move only the part that needs it. Weighing it up in detail? See our full pgvector vs Pinecone comparison. Comparing the whole field, Pinecone, Qdrant, Weaviate, Milvus, and Chroma? See our guide to the best vector database for RAG.

pgvector vs a dedicated vector database, at a glance

Factor pgvector on Postgres Dedicated vector DB
(Pinecone, Qdrant, Weaviate, Milvus, Chroma)
Architecture An extension on the Postgres you already run A separate system to provision and operate
Data consistency Transactional with your rows, no drift Eventual, kept in sync by a pipeline
Querying SQL joins, filters, and similarity in one query Vector API, joins handled in your app
Scale sweet spot Comfortably into the millions of vectors Hundreds of millions to billions
Backups & recovery Same PITR, backups, and forking as Postgres A separate backup and recovery story
Cost One database bill, from $5/mo An extra service on top of your database

Getting started

Turn it on in one click.
We handle the rest.

Pick Vector Database when you create a managed PostgreSQL instance, or enable pgvector on a Postgres database in a project. You can also switch it on for an existing Postgres instance from its settings. We run CREATE EXTENSION vector and tune work_mem and maintenance_work_mem for vector workloads, so it is ready the moment the database is.

Frequently Asked Questions

What is a vector database?
A vector database stores data as vectors, lists of numbers called embeddings that capture the meaning of text, images, audio, or code. Instead of matching exact keywords, it finds the items whose vectors are closest to your query, so you can search by meaning and similarity. It is the storage and search layer behind semantic search, recommendations, and retrieval-augmented generation (RAG).
Is PostgreSQL a vector database?
With the pgvector extension, yes. pgvector adds a native vector column type, similarity operators, and indexing (HNSW and IVFFlat) to PostgreSQL, so a standard Postgres instance can store embeddings and run nearest-neighbour search right alongside your relational data.
What is pgvector?
pgvector is the open-source PostgreSQL extension for vector similarity search. It lets you store embeddings in a vector column, index them for speed, and query by cosine, L2, or inner-product distance, all in regular SQL.
Do I need a dedicated vector database for RAG?
For most applications, no. pgvector handles retrieval for RAG comfortably into the millions of vectors, and keeping embeddings in the same Postgres database as your content removes an entire sync pipeline. A standalone vector database mainly pays off at very large scale or extreme query rates. For the full comparison of every option, see which vector database fits your RAG app.
How does pgvector compare to Pinecone, Weaviate, or Milvus?
Pinecone, Weaviate, Milvus, Qdrant, and Chroma are standalone vector databases you run and pay for on top of your primary database. pgvector keeps vectors inside the Postgres you already use, so you get transactional consistency, SQL joins, and one system to operate. Specialist databases can pull ahead at billion-vector scale or very high query rates.
Is pgvector open source?
Yes. pgvector is open source and runs on standard PostgreSQL, so your embeddings and queries stay portable with no proprietary lock-in.
Which distance metrics and index types are supported?
pgvector supports L2 (Euclidean), cosine, and inner-product distance, with HNSW and IVFFlat indexes for fast approximate nearest-neighbour search.
How do I enable pgvector on Selfhost.dev?
When you create a managed PostgreSQL instance, choose Vector Database, or enable pgvector on an existing Postgres instance from its settings. In a project, pick Vector Database when you add a Postgres database. We run CREATE EXTENSION and tune work_mem and maintenance_work_mem for vector workloads.
How many vectors can it handle?
pgvector scales to millions of vectors on a single instance with an HNSW index, and you can resize the instance, add storage, and tune memory as your dataset grows. Most semantic search and RAG workloads fit comfortably.
Are my vectors backed up?
Yes. Embeddings live in your Postgres database, so they are covered by the same automated backups, point-in-time recovery, encryption at rest, and forking as the rest of your data.

Your vector database
is one Postgres away.

pgvector, enabled in one click
Open source, pay-as-you-go from $5/mo
Create a vector database