← All tutorials
Vector Databases

Vector databases β€” where embeddings live

A vector database stores embeddings (plus their metadata) and answers one question extremely fast: which stored vectors are nearest this query vector? That "nearest-neighbour" search is the retrieval engine behind semantic search and RAG. The options range from a one-line library to a distributed cluster β€” this guide compares them.

embed & store vectors→ build an ANN index→ query → nearest top-k
The real question isn't "which brand?" It's "which kind?" β€” an in-process library, a full database server, a managed cloud service, or a vector feature bolted onto a database you already run. That choice matters more than the logo.

Why  The problem β€” nearest neighbours at scale

Finding the closest vectors exactly means comparing the query against every stored vector β€” O(NΒ·d). Over millions of high-dimensional vectors that's far too slow for interactive search. Vector databases solve this with Approximate Nearest Neighbour (ANN) indexes that trade a tiny bit of accuracy (recall) for enormous speed-ups β€” plus the un-glamorous-but-essential parts: metadata filtering, persistence, updates, and scaling.

The core trade-off: recall vs latency. An ANN index returns almost all the true nearest neighbours, much faster. You tune how close to exact you need to be.

Mechanics  How they work

Every vector database, big or small, does the same four jobs:

πŸ—ƒοΈ Store

Keep vectors + metadata (source, tags, timestamps) durably, with add/update/delete.

🧭 Index (ANN)

Build a structure β€” HNSW graph, IVF clusters, PQ compression β€” for fast approximate search.

πŸ“ Metric

Compare with cosine, dot product or Euclidean β€” matched to how the embeddings were trained.

πŸ”Ž Filter

Combine vector similarity with metadata filters (source = "kb") and often keyword/hybrid search.

At query time: embed the query with the same model used for indexing, run ANN search for the top-k nearest, apply filters, and return the matches (with their original text/metadata) to feed a model.

The ANN algorithms in one line each

HNSW β€” a navigable small-world graph you greedily walk toward the query; great recall/latency, memory-hungry. IVF β€” cluster vectors, search only the nearest clusters. PQ (product quantization) β€” compress vectors to save memory at some accuracy cost. DiskANN β€” graph indexes that live on SSD for billion-scale sets. Most databases default to HNSW.

At a glance  The landscape

The options spread across two axes: how much you run yourself (a library ↔ a managed service) and how much scale you're built for.

The vector-database landscape A scatter positioning vector databases by how much you self-manage (library to managed cloud, left to right) versus scale (prototype to production, bottom to top). FAISS and Chroma sit lower-left; pgvector mid-left; Qdrant and Weaviate mid; Milvus high for massive scale; Pinecone upper-right as managed; Redis, Elasticsearch and Mongo mid-right as existing databases with vector features. β—€ library / embedded managed cloud β–Ά prototype β–² production scale FAISS Chroma pgvector Qdrant Weaviate Milvus Pinecone Redis Β· ES Β· Mongo

No point is "best" β€” each occupies a sensible niche. The trick is knowing your position: how much ops you'll take on, and how big you'll get.

The field  The options

Chroma OSS Β· embedded or server

Niche The easiest on-ramp β€” embeds in your Python process, persists to disk, and can embed text for you. Choose prototyping and local RAG.

FAISS OSS library (Meta) Β· in-process

Niche A blazing-fast similarity-search library, not a database β€” no server, filtering or persistence out of the box. Choose static, read-heavy, research or custom pipelines where you manage storage yourself.

Qdrant OSS server (Rust) Β· self-host or cloud

Niche A production-grade server with rich metadata filtering and good performance. Choose balanced self-hosted production with strong filtering.

Weaviate OSS server Β· self-host or cloud

Niche Feature-rich with first-class hybrid search (vector + keyword) and modules. Choose when hybrid search and built-in modules matter.

Milvus OSS Β· distributed

Niche Built for massive scale β€” billions of vectors across a distributed cluster. Choose very large deployments that need horizontal scale.

Pinecone managed cloud (serverless)

Niche Fully managed β€” no infrastructure to run; scales for you. Choose hands-off production when you'd rather not operate a database.

pgvector PostgreSQL extension

Niche Adds a vector column and ANN search to Postgres β€” vectors live beside your relational data, filtered with plain SQL. Choose when you're already on Postgres and want one datastore.

Redis Β· Elasticsearch/OpenSearch Β· Mongo Atlas existing DBs + vectors

Niche Databases you may already run have added vector/kNN search. Choose to avoid a new system when you're already invested in one of them.

Concretely  Three kinds, three snippets

The same "store + search" in three kinds of vector store β€” an embedded library, a managed service, and a SQL extension. Switch tabs; hit Copy.

store & query
# Embedded library β€” it can even embed the text for you.
import chromadb
client = chromadb.PersistentClient("./db")
col = client.get_or_create_collection("docs")

col.add(ids=["1"], documents=["Our refund policy…"], metadatas=[{"src": "kb"}])
print(col.query(query_texts=["how do I get money back"], n_results=3))
Same shape, different homes. Notice the flow β€” add vectors, query for nearest with a filter β€” is identical. What changes is who runs the index and how it's queried. That's why you can start embedded and graduate to a server later without redesigning your pipeline.

Comparison table

StoreKindHostingFilteringScaleBest for
ChromaOSS databaseEmbedded / serverYesSmall–medPrototyping, local RAG
FAISSOSS libraryIn-processDIYLarge (static)Research, read-heavy, custom
QdrantOSS databaseSelf-host / cloudRichLargeBalanced production
WeaviateOSS databaseSelf-host / cloudRich + hybridLargeHybrid search, modules
MilvusOSS databaseSelf-host / cloudYesMassive (distributed)Billions of vectors
PineconeManagedCloud onlyYesLargeHands-off production
pgvectorPostgres extensionWherever PG runsSQL WHEREMedAlready on Postgres
Redis Β· ES Β· MongoExisting DB + vectorsVariousYesMed–largeAlready using them

When to choose which

If you…Reach for…
Are prototyping locally with no infrastructureChroma or FAISS
Are already running PostgreSQLpgvector
Want hands-off, managed productionPinecone
Want self-hosted production with rich filteringQdrant or Weaviate
Need hybrid (vector + keyword) search built inWeaviate (or Qdrant/ES)
Have billions of vectors / need distributed scaleMilvus
Already run Redis / Elasticsearch / MongoTheir vector features
Rule of thumb. Start embedded (Chroma/FAISS) to build the pipeline, then move to a server (Qdrant/Weaviate/Pinecone/pgvector) when you need scale, filtering or persistence β€” the embed β†’ upsert β†’ query flow stays the same. And prefer a store you already operate over adding a new system.

Cheat sheet

QuestionShort answer
What does a vector DB do?Store embeddings + metadata and find the nearest vectors to a query, fast.
Why not exact search?Exact is O(NΒ·d) β€” too slow at scale; ANN indexes trade a little recall for big speed.
Common ANN index?HNSW (a navigable graph); also IVF, PQ, DiskANN.
Library vs database vs managed?FAISS = library; Chroma/Qdrant/Weaviate/Milvus = databases; Pinecone = managed; pgvector = Postgres.
Golden rule?Same embedding model for indexing & querying; matched distance metric.
How to start?Embedded (Chroma/FAISS) β†’ graduate to a server when you need scale.

Knowledge check

Six questions on vector databases. Pick an answer for each, then check your score.

1. What does a vector database primarily do?

2. Why do vector databases use ANN instead of exact search?

3. Which is a library (not a full database) β€” no server, filtering or persistence out of the box?

4. You're already running PostgreSQL and want vectors beside your relational data. Best fit?

5. You want a fully managed vector database with no infrastructure to operate. Best fit?

6. What's the golden rule for indexing and querying?

Next steps

🧬 Embedding models

Where the vectors come from β€” how text becomes the vectors these databases store.

πŸ”Ž RAG vs CAG vs GraphRAG

Retrieval in context β€” vector search is the engine behind RAG.

πŸ“„ Deep-dive write-up

The full markdown guide β€” storing chunk data across Chroma, FAISS, Qdrant, Pinecone, pgvector.

πŸ““ All tutorials

The hub β€” LLMs, embeddings, retrieval, agents & more.