Key takeaways

  • A vector database stores embeddings and returns the stored items closest in meaning to a query, which is the retrieval step in most RAG apps.
  • Approximate nearest neighbor indexes such as HNSW and IVF trade a little recall for much faster search, with settings like ef_search and nprobe to tune the trade.
  • If your data already lives in PostgreSQL, pgvector is usually enough to start; dedicated databases help with very large scale, heavy filtering and hybrid search.

A vector database stores embeddings, which are lists of numbers that capture what a piece of text or an image means, and quickly finds the stored items whose numbers are closest to a query's. That lets software search by meaning instead of exact words. Most AI apps use one to fetch the right documents before a language model answers, a pattern called retrieval-augmented generation, or RAG.

Some products are built only for this job: Pinecone, Weaviate, Qdrant, Milvus and Chroma. Others add vector search to a database you already run, most famously pgvector for PostgreSQL.

Embeddings: what a vector database stores

An embedding model turns data into a fixed-length list of numbers. Qdrant's docs call embeddings "fixed-length lists of numbers that represent the data's conceptual essence." Similar things land close together: "How do I reset my password" and "I forgot my login" share almost no words, but a good model puts them near each other, so a vector search finds the match a keyword index misses. For more, see what embeddings are and how they work.

The database keeps each vector next to an ID, the original text and metadata such as which customer owns it.

How similarity search works

You embed the query with the same model and ask for the nearest stored vectors. pgvector supports the common distance measures: cosine distance (the angle between vectors), Euclidean or L2 distance (straight-line distance) and inner product. In pgvector it is one SQL query. The README's example returns the five nearest rows by L2 distance:

SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;

By default pgvector compares the query with every stored vector, an exact search that "provides perfect recall." With millions of long vectors, that is too slow for an app someone is waiting on.

Approximate nearest neighbor indexes: HNSW and IVF

Approximate nearest neighbor (ANN) indexes look at a small part of the data and return results that are almost always, but not always, the true nearest neighbors. The share of true neighbors found is called recall. Every index trades some recall for speed, with settings to move along that trade.

HNSW: a layered graph

HNSW, for Hierarchical Navigable Small World, comes from a 2016 paper by Yu. A. Malkov and D. A. Yashunin. It links each vector to a few neighbors in a graph, and stacks several such graphs. The top layer holds a few vectors with long links; each layer below holds more, and the bottom holds all of them. A search starts at the top, jumps toward the query in big steps, then drops down and takes smaller ones, like zooming in on a map. The authors report "logarithmic complexity scaling," so ten times the data costs far less than ten times the search time.

In pgvector, m (links per vector per layer) defaults to 16, ef_construction to 64, and the query-time hnsw.ef_search to 40. A higher ef_search improves recall and slows the query. The cost of HNSW is memory and build time; Weaviate's docs note that the in-memory index grows with the vector count and suggest quantization, storing each number in fewer bits, to shrink it.

IVF: clusters you search a few of

IVF, short for inverted file, groups vectors into clusters with k-means, as Milvus's docs explain. A query is compared with each cluster's center, and only the closest clusters are scanned. nlist sets how many clusters to build (Milvus default: 128); nprobe sets how many to scan (default: 8). If the true nearest neighbor sits in a cluster you skipped, you miss it.

pgvector's version, IVFFlat, builds faster and uses less memory than HNSW but gives a worse speed-to-recall trade. It learns clusters from the data, so build it after loading the table. The README suggests rows / 1000 lists up to a million rows and sqrt(rows) above that.

Both ideas also live in FAISS, Meta's MIT-licensed library for similarity search, with optional GPU support. It is a library, not a database, described in The Faiss library (Douze et al., 2024).

How a vector database fits into RAG

RAG gives a language model the documents it needs at question time. Milvus describes itself as the retrieval layer for "applications like RAG and semantic search." The flow:

  1. Ingest. Split documents into chunks, embed each chunk, and store the vectors with the text and metadata.
  2. Query. Embed the user's question, fetch the nearest chunks, usually with a filter such as "only this customer's files," and put them in the model's prompt.

Filters matter because real apps rarely search everything. Pinecone suggests namespaces to keep each tenant's data apart in one index. Qdrant applies filters during the HNSW graph walk itself. If you would rather not run any of this, see RAG as a service and managed RAG pricing.

When Postgres with pgvector is enough

If your app already runs on PostgreSQL, start with pgvector. Vectors sit in the same rows as the data they describe, so one query can join embeddings with users and permissions. You keep what the README calls "ACID compliance, point-in-time recovery, JOINs," and replication works because pgvector writes to the write-ahead log. For the database itself, see our article on the PostgreSQL 19 release.

Know the limits first:

  • Indexed dimensions. HNSW and IVFFlat index vector columns of up to 2,000 dimensions; the half-precision halfvec type raises that to 4,000.
  • Filtering. With approximate indexes, "filtering is applied after the index is scanned." If 10% of rows match and ef_search is 40, about 4 rows come back on average. Version 0.8.0 added iterative index scans that keep scanning until enough rows match.
  • One server. The index shares memory and CPU with your other queries.

When a dedicated vector database makes sense

  • Very large scale. Milvus Distributed runs on Kubernetes; Milvus says it reached "tens of billions" of vectors in 2023.
  • Heavy filtering. Qdrant builds filters into the graph search, so narrow filters don't starve results.
  • Hybrid search. Pinecone says one index can serve full-text, semantic and sparse-vector search, and can embed raw text server-side.
  • No ops team. Every option below has a managed cloud with a free tier.
  • A laptop prototype. Chroma runs locally, and Milvus Lite is a Python library with no server.

The choice of database usually matters less than how you chunk documents and which embedding model you use. Pick what your team can run with the least new work, and move when you hit a real limit.

Vector database options compared

Self-hosting the open-source versions costs only your servers.

Option License How you run it Managed pricing (as of November 23, 2026)
pgvector PostgreSQL License Extension in any PostgreSQL No separate price; you pay for Postgres
Pinecone Proprietary Managed cloud, or Bring Your Own Cloud Starter free (2 GB); Builder $20/month; Standard $50/month minimum usage; Enterprise $500/month minimum
Weaviate BSD-3-Clause, some enterprise features licensed separately Self-host or Weaviate Cloud Free (100,000 objects); Flex from $45/month; Premium from $400/month
Qdrant Apache 2.0 Self-host, managed, hybrid or private cloud Free cluster (1 GB RAM, 4 GB disk); paid tiers usage-based, no list price
Milvus Apache 2.0 Milvus Lite, Standalone (Docker), Distributed (Kubernetes), or Zilliz Cloud Zilliz free tier (5 GB); Serverless from $0; Dedicated from $126/month
Chroma Apache 2.0 Local, self-host or Chroma Cloud Starter $0 plus usage with $5 monthly credits; Team $250/month plus usage

Zilliz, the company that started Milvus, runs its managed cloud. Weaviate's license keeps one directory under a separate enterprise license.

Frequently asked questions

What is the difference between a vector database and a relational database?

A relational database finds rows by exact values, such as an ID or a date range. A vector database finds rows whose embeddings are closest to a query's, which means searching by meaning. pgvector adds the second ability to PostgreSQL, so one database can do both.

Do I need a vector database for RAG?

You need vector search, not necessarily a separate database. For a few thousand chunks, exact search in pgvector or even in memory is fine. Dedicated vector databases pay off at large scale, with heavy metadata filtering, or when you want a managed service.

Is there a free vector database?

Yes. pgvector, Weaviate, Qdrant, Milvus and Chroma are open source and free to self-host. As of November 23, 2026, Pinecone, Weaviate Cloud, Qdrant Cloud, Zilliz Cloud and Chroma Cloud also offer free managed tiers with size limits.

Which vector databases are open source?

pgvector uses the PostgreSQL License, Qdrant, Milvus and Chroma use Apache 2.0, and Weaviate is BSD-3-Clause apart from some enterprise features. Pinecone is a proprietary managed service. FAISS, from Meta, is an MIT-licensed library rather than a database.

Sources

  1. pgvector: open-source vector similarity search for Postgrespgvector
  2. Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphsarXiv (Malkov and Yashunin)
  3. The Faiss libraryarXiv (Douze et al.)
  4. Faiss repositoryMeta
  5. IVF_FLAT indexMilvus
  6. What is MilvusMilvus
  7. Vector indexingWeaviate
  8. Weaviate licenseWeaviate
  9. Qdrant documentation overviewQdrant
  10. Pinecone Database overviewPinecone
  11. Chroma introductionChroma
  12. Pinecone pricingPinecone
  13. Weaviate pricingWeaviate
  14. Qdrant pricingQdrant
  15. Zilliz Cloud pricingZilliz
  16. Chroma Cloud pricingChroma