CoderBlog
AI Tech

Vector Databases Demystified: From Embeddings to Production Search in 2026

A working engineer's guide to vector databases in mid-2026 — embeddings, ANN indexes, the choices that matter in production, and when you do not need a vector DB at all.

Every conversation about retrieval-augmented generation in 2026 eventually lands on a vector database. The promise is straightforward: take a chunk of text, embed it as a high-dimensional vector, store the vector, and at query time find the vectors that are closest in meaning. The implementations are not straightforward. There are fifteen serious vector databases on the market, three open-source ANN libraries, four major cloud offerings, and a Postgres extension that handles the same workload for most teams. The choice between them is the difference between a RAG system that responds in 200 milliseconds and one that responds in 4 seconds. It is the difference between a system that holds up at 10,000 documents and one that holds up at 10,000,000. It is the difference between a system you understand and a system you hope works.

This is what vector databases actually do, what the production tradeoffs look like in 2026, and when the right answer is to skip the vector database entirely and use something you already have.

Cover image: vector databases

Fig. 01 — A high-dimensional vector field, projected onto two dimensions. Every dot is a document. The clusters are what you search.

What an Embedding Actually Is

The starting point for the entire vector database story is the embedding. An embedding is a function that takes some content — text, image, audio, code — and returns a vector of fixed dimension, typically 384, 768, 1024, 1536, or 3072 floating-point numbers. The function is trained so that two pieces of content with similar meaning have vectors that are close to each other in the high-dimensional space, where "close" is measured by cosine similarity or Euclidean distance.

The training is the interesting part. The model that produces the embedding — OpenAI's text-embedding-3-small, Cohere's embed-english-v3.0, the open-source bge-large-en-v1.5, the nomic-embed-text-v1.5 family — is a transformer that has been fine-tuned on a contrastive task. The training data is pairs of texts where one is a query and the other is a relevant document. The model learns to produce vectors that put the query and the relevant document close together in the space, and the query and the irrelevant document far apart.

The result is a function that has no idea what the words mean, but has a remarkable ability to tell when two pieces of text are about the same thing. "How do I reset my password" and "I forgot my login credentials" produce vectors that are 0.91 cosine similar. "How do I reset my password" and "What is the capital of France" produce vectors that are 0.12 cosine similar. The model has no concept of "password" or "France." It has only the geometry of the space, learned from examples.

This is also the source of the most common production failure. The embedding is a black box. You cannot debug it by reading the code. You cannot reason about it by reading the documentation. You can only test it against your own data. The choice of embedding model is a choice that you validate against your queries, not a choice you make from a benchmark. The benchmark numbers are useful, but the only number that matters is the one you measure on your own corpus.

The Index, Honestly

The naive way to do nearest-neighbor search is to compare the query vector to every stored vector. For 1,000 documents, this is fine. For 100,000 documents, this is borderline. For 1,000,000 documents, this is unusable. For 10,000,000, this is absurd. The cost of the naive search is O(n) per query, and that does not scale.

The non-naive way is an approximate nearest neighbor (ANN) index. The standard algorithms in 2026 are HNSW (Hierarchical Navigable Small World), IVF (Inverted File), and ScaNN. HNSW is the default choice for most workloads, because it has the best recall-vs-latency tradeoff for moderate dimensionality (up to about 2000 dimensions). IVF is the right choice for very high dimensionality or very large datasets, because it scales better. ScaNN is the right choice if you are willing to invest in tuning, because it can match HNSW recall at lower latency.

The trade-off is between recall, latency, memory, and build time. HNSW gives you 95% recall at 10 milliseconds for 1 million vectors in 768 dimensions on a single modern server. IVF gives you 90% recall at 5 milliseconds for the same workload, but you have to tune the cluster count. ScaNN gives you 99% recall at 8 milliseconds, but you have to train it. Every vector database is a different combination of these tradeoffs, plus their own indexing tricks.

The thing that took me a while to internalize is that the choice of index is rarely the bottleneck. The embedding model is the bottleneck. The query latency is the bottleneck. The recall is the bottleneck. The index choice is the difference between a 10-millisecond query and a 12-millisecond query. The embedding model is the difference between a relevant result and an irrelevant result. Optimize the right thing.

The Choices That Matter in Production

The 2026 vector database landscape, ranked by how much I would recommend them to a working engineer in mid-2026.

pgvector for teams that already have Postgres. This is the right starting point for most teams. The extension adds a vector type to Postgres, an ANN index based on HNSW or IVF, and the usual distance operators. The performance is good enough for most workloads (10,000 to 1,000,000 documents). The operational story is the same as your existing Postgres. The backup story is the same. The disaster recovery story is the same. The skill your team already has applies directly. If you outgrow pgvector — and most teams will not — you can migrate to a dedicated vector database with a one-time ETL.

-- the entire schema
CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE documents (
    id          BIGSERIAL PRIMARY KEY,
    content     TEXT NOT NULL,
    embedding   VECTOR(1536) NOT NULL,
    metadata    JSONB DEFAULT '{}'::jsonb,
    created_at  TIMESTAMPTZ NOT NULL DEFAULT now()
);

CREATE INDEX documents_embedding_hnsw ON documents
    USING hnsw (embedding vector_cosine_ops)
    WITH (m = 16, ef_construction = 64);

-- the entire query
SELECT id, content, 1 - (embedding <=> $1) AS similarity
FROM documents
ORDER BY embedding <=> $1
LIMIT 10;

pgvector is the boring, correct, sufficient choice. It is the choice I would make for a team of fewer than 10 engineers building their first RAG system.

Pinecone for teams that have outgrown Postgres. Pinecone is a managed vector database, fully serverless, with strong multi-tenant isolation, sub-100-millisecond p99 latency, and a pricing model that scales linearly with storage. The integration story is good. The operational story is good. The downside is the price — at scale, Pinecone is meaningfully more expensive than pgvector, and the cost difference grows with the data size. If you have a million documents, the cost difference is real. If you have 100 million documents, the cost difference is significant.

Weaviate or Qdrant for teams that need to host themselves. Both are open-source, self-hostable, with active development and a real ecosystem. Weaviate has the better ingestion pipeline. Qdrant has the better query engine. Either is a good choice if you need to run on your own infrastructure for compliance reasons, or if you have outgrown pgvector and want to avoid Pinecone's pricing.

LanceDB for teams that want embedded. LanceDB is an embedded vector database that runs in-process with your application. No server. No managed service. The data lives in a directory on disk. The API is Python or Rust. If you are building a single-machine application — a desktop app, a CLI tool, an edge device — LanceDB is the right choice. The performance is good, the operational story is trivial, and the licensing is open.

qdrant, milvus, vespa for teams that need to go very fast at very large scale. These are the production-grade vector databases for the truly large workloads. If you have 100 million documents, 10,000 queries per second, and a team that can operate a vector database, one of these is your answer. If you have fewer than 10 million documents and fewer than 100 queries per second, you do not need them.

The Engineering Practices That Make It Work

The practices that will save you a quarter of debugging time.

Evaluate the embedding model on your own data. The benchmarks on the embedding model page are not your benchmarks. Take 100 queries from your actual production traffic, embed them with the model you are considering, retrieve the top 10 results, and grade them by hand. The model that wins the benchmark is not always the model that wins on your data. The 2 days you spend on this evaluation are the highest-leverage 2 days in the project.

Index, then query, then re-rank. A vector search is fast, but the results are approximate. The result list is the candidates, not the answer. Take the top 100 results from the vector search, then re-rank them with a cross-encoder model or a more expensive embedding model. The two-stage retrieval is the difference between 80% recall and 95% recall. The two-stage retrieval is also the difference between a 50-millisecond query and a 200-millisecond query. Budget for both.

Use metadata filtering aggressively. A vector search is most useful when it is scoped. Search for the 10 documents most similar to the query, but only among the documents with metadata.category = "api-docs". The filter cuts the search space by 10x or 100x, and the recall is much higher because you are not comparing against irrelevant documents. Most vector databases support pre-filtering (filter before the search) and post-filtering (filter after the search). Pre-filtering is usually the right choice.

Cache aggressively. Embeddings are deterministic for a given model and input. A query that has been embedded before can be cached, and the cached embedding can be used to look up the cached results. The cache hit rate for a RAG system in production is usually 30-50%, and the cache layer saves you real money. Redis works. An in-process LRU works. Whatever you have works.

Set a recall floor, not a latency floor. A vector search should hit a minimum recall (usually 95%) regardless of latency. The system should be tunable to hit that floor. If the recall drops below the floor, the system is broken, even if the latency is good. The latency is the optimization target, but the recall is the correctness target.

When to Skip the Vector Database

The list of cases where the vector database is the wrong tool.

You have fewer than 10,000 documents. A brute-force scan is fast enough. The index will be slower than the scan, because the index has overhead. Save yourself the operational complexity.

Your queries are exact-match, not semantic-match. A traditional search engine (Postgres full-text, Elasticsearch, Meilisearch) is the right tool. The vector database is the wrong tool. The semantic model is the wrong model.

You are building a one-shot RAG system for a demo. Use langchain or llamaindex with an in-memory store. Skip the database. The data is not persistent. The system is not production. The complexity is not justified.

You can express the query as a structured filter. If 90% of your queries are "documents with this metadata, sorted by this field," you do not need a vector database. You need a query engine. The vector database is for the 10% that are semantic.

For the rest — RAG over a knowledge base, semantic search over a corpus, recommendation, anomaly detection, image search, anything where the meaning of the input matters — the vector database in 2026 is a mature, well-understood, well-tooled piece of infrastructure. The choice between the implementations is a real choice, but the choice to use one is not. Use one. The question is which one.

The Shape of What Comes Next

The vector database market is consolidating. The next two years will see the smaller players acquired, the larger players commoditized, and the open-source implementations stabilize around pgvector and one or two of the dedicated systems. The interesting questions in 2027 are not "which vector database" but "which embedding model" and "which retrieval architecture." The infrastructure layer is becoming boring. That is the goal. Boring infrastructure is the infrastructure that works.

A small toolkit to get started, if you have not already: install pgvector on your existing Postgres (it is a one-line CREATE EXTENSION), embed your documents with an embedding model you have evaluated on your own data, store the embeddings in a vector column, query with <=> for cosine distance. The first query takes 20 minutes. The 100th query takes 10 minutes. The 1,000th query is muscle memory. The system is yours, the data is yours, the operational story is one your team already knows. That is the renaissance.

Winson Yau

Engineer, writer, and founder of CoderBlog. Building tools and writing about the craft of software from Hong Kong.

Comments

Discuss the article below. Markdown is supported. Sign in with email or GitHub to leave a comment.