A vector database is a purpose-built storage system that indexes high-dimensional embeddings and retrieves them by geometric similarity rather than exact keyword match. The shift matters because modern AI applications operate on meaning, not strings: a user asks a question, an embedding model turns the query into a numeric array, and a vector database returns the stored arrays that sit closest in that high-dimensional space. Pinecone, Weaviate, Chroma, Qdrant, Milvus, FAISS, and MongoDB Atlas Vector Search all solve that same retrieval problem with different deployment models, index structures, and integration surfaces. Behind every retrieval-augmented generation (RAG) chatbot, every semantic search bar, and every recommendation feed grounded in embeddings, a vector database is doing the geometric lookup. The mechanics of how it stores those arrays, how it indexes them with HNSW or IVF, how it combines dense and sparse signals through hybrid search, and how it differs from a SQL table are what determine whether the lookup arrives in 20 milliseconds or 2 seconds. Those details, and the vendor trade-offs that follow from them, are what this guide unpacks.
What a Vector Database Actually Stores
A vector database stores embeddings, numeric arrays where each dimension encodes a learned feature of the source content, and organizes them so that geometrically similar vectors can be found in milliseconds. Each record is a fixed-length float array produced by an embedding model such as OpenAI's text-embedding-3 family, Cohere Embed, or a model hosted inside the vector DB itself. Pinecone's generate-embeddings endpoint documents that it uses Pinecone-hosted embedding models to turn raw text into the dense float arrays the index then stores (Pinecone, generate-embeddings reference). Weaviate exposes a parallel surface: its own embeddings module generates vectors for collections using a configured model and a Weaviate API key (Weaviate, Weaviate Embeddings model provider). Alongside the float array, each row carries an identifier, optional metadata such as document ID, title, or timestamp, and sometimes the raw text chunk for return to the application. For background on the wider stack these systems plug into, see how modern generative AI systems work, and for the retrieval pattern that drives most production deployments, how retrieval-augmented generation works end to end.
- Embedding: a fixed-length float array where every dimension encodes a learned semantic feature of the source content.
- Dimension count: the array length, typically 384, 768, 1024, 1536, or 3072 depending on the embedding model.
- Metadata payload: structured fields attached to each vector, used for filtering at query time.
- Namespace or collection: a logical partition inside the vector store that isolates one tenant or document set from another.
How Vector Databases Index Embeddings
A vector database must trade exact recall for speed when the index contains millions of vectors, which is why most production deployments use approximate nearest neighbor (ANN) algorithms rather than brute-force scan. A flat index compares the query vector to every stored vector and returns the true nearest neighbors, but its cost grows linearly with the corpus and breaks down well before the million-vector mark. ANN index structures sacrifice a small slice of recall for two or three orders of magnitude lower latency. HNSW (Hierarchical Navigable Small World) builds a layered graph: queries enter at a sparse top layer, greedily walk toward the query vector, and descend through denser layers until they converge on a local neighborhood. IVF (Inverted File) partitions the space with k-means into a few thousand cells and searches only the cells closest to the query. Product Quantization (PQ) compresses each vector into a short code so that more of the index fits in RAM, and IVF-PQ stacks the two ideas. FAISS, the Meta-built library, popularized these structures and remains the reference implementation under the hood of several managed vector stores. SQL Server 2025 takes a similar step from the relational side: Microsoft documents that SQL Server 2025 introduces support for approximate search through a vector index, trading exact similarity for materially better performance (Microsoft, EF Core vector search on SQL Server).
| Index type | Recall | Latency at 1M vectors | Memory profile | Best for |
|---|---|---|---|---|
| Flat (brute force) | 100% exact | Slow, linear in corpus size | High, full vectors in RAM | Small corpora and ground-truth benchmarking |
| HNSW | 95-99% typical | Single-digit milliseconds | High, graph plus full vectors | Low-latency RAG with frequent reads |
| IVF | 90-95% typical | Tens of milliseconds | Moderate, cell centroids only | Larger corpora where build time matters |
| IVF-PQ | 85-92% typical | Tens of milliseconds | Low, quantized codes | Hundred-million-vector indexes on constrained hardware |
Similarity Search: How Queries Actually Work
A vector database answers a query by converting the query text into an embedding and then scanning the index for stored vectors whose geometric distance is smallest. The distance metric is a configuration choice with real consequences. Cosine similarity measures the angle between two vectors and ignores magnitude, which makes it the default for text embeddings normalized to unit length. Dot product produces the same ranking as cosine when vectors are normalized but can favor longer vectors when they are not. Euclidean distance (L2) measures straight-line distance in the embedding space and tends to be the default for image and audio embeddings where magnitude carries signal. Pinecone's LangChain integration documents the developer ergonomics: the similarity_search method accepts raw text and automatically embeds it using the Embedding object configured on the PineconeVectorStore, so application code passes a string rather than a precomputed vector (Pinecone, LangChain integration). The result is a ranked list of top-k matches, each with an identifier, the original metadata, and a similarity score the application can threshold or rerank.
- Embed the query: the application sends the query string to an embedding model and receives a float array of matching dimension.
- Probe the index: the vector store walks its HNSW graph or IVF cells to find candidate neighbors close to the query vector.
- Score candidates: the database computes cosine similarity, dot product, or Euclidean distance between the query and each candidate.
- Apply filters: metadata predicates remove rows that do not match required fields such as tenant ID or document type.
- Return top-k: the highest-scoring matches come back with identifier, metadata, similarity score, and optionally the raw chunk text.
Hybrid Search and Metadata Filtering
A vector database that supports hybrid search combines dense vector similarity with keyword scoring, so a RAG pipeline can match by both semantic meaning and exact term presence simultaneously. Pure semantic search reads intent well but loses precision on specific product codes, error strings, and proper nouns. A query for "error code KB5034441" embeds to a region of the space that also includes adjacent error codes and unrelated Windows update articles, and the literal code can drop out of the top results. Hybrid search adds a sparse vector or BM25 keyword score and fuses the two rankings, often with reciprocal rank fusion. Weaviate documents the pattern directly: its query model lets developers combine semantic search and lexical scalar search in a single query, with a vector search allowing similarity-based retrieval and lexical search anchoring exact terms (Weaviate, query tutorial). MongoDB Atlas Vector Search ships the same idea inside the broader MongoDB query layer: its documentation describes querying data by semantic meaning, combining vector search with full-text search, and filtering on other fields in the same collection (MongoDB, Vector Search overview).
- Dense vector score: cosine similarity or dot product against the query embedding, capturing semantic meaning.
- Sparse keyword score: BM25 or a sparse vector that weights term overlap and rewards exact matches.
- Score fusion: reciprocal rank fusion or weighted sum combines the two rankings into a single ordered list.
- Metadata filter: structured predicates such as tenant_id, language, or published_after that run alongside the similarity scan.
- Reranker: a cross-encoder pass over the top results, often used after hybrid search to lift precision on the final top-k.
Vector Database Options Compared: Pinecone, Weaviate, Chroma, Qdrant, Milvus, FAISS
A vector database product choice comes down to deployment model, scale ceiling, and how tightly the tool integrates with the rest of the AI stack. Pinecone is a fully managed serverless service: its LangChain integration page positions it as a high-performance vector database enabling scalable, real-time recommendation and search systems based on vector similarity search (Pinecone, LangChain integration), and its test-at-scale guide documents an import feature that loads millions of vectors from object storage in parallel for fast initial ingest (Pinecone, test at scale). Weaviate is open-source and self-describes as an open-source AI vector database designed to store and index both data objects and their vector embeddings, with native semantic and hybrid search (Weaviate documentation). Chroma is the in-process Python-first option that many teams reach for during prototyping. Qdrant is a Rust-based open-source store with strong filtering and a managed cloud. Milvus is the Zilliz-stewarded distributed system aimed at the largest deployments, with support for multiple index types including HNSW and IVF variants. FAISS, originally from Meta, is a library rather than a database and is what several managed stores embed internally for the index itself. MongoDB Atlas Vector Search sits inside an existing MongoDB cluster and integrates similarity scoring with the rest of the document model. For the model layer these stores typically sit behind, see how large language models are trained and deployed.

| System | Deployment | License | Index types | Hybrid search | Typical fit |
|---|---|---|---|---|---|
| Pinecone | Managed serverless | Proprietary | Proprietary ANN | Yes, sparse-dense | Hands-off RAG at production scale |
| Weaviate | Self-hosted or managed cloud | Open source (BSD-3) | HNSW | Yes, native | Open-source RAG with semantic plus lexical |
| Chroma | In-process or server | Open source (Apache license) | HNSW | Limited | Local prototyping and small apps |
| Qdrant | Self-hosted or managed | Open source (Apache license) | HNSW | Yes, sparse-dense | Filter-heavy workloads in Rust-friendly stacks |
| Milvus | Distributed self-hosted or Zilliz cloud | Open source (Apache license) | HNSW, IVF, IVF-PQ | Yes | Hundred-million-plus vector indexes |
| FAISS | Library, in-process | Open source (MIT) | Flat, HNSW, IVF, IVF-PQ | No | Embedded index inside a custom service |
| MongoDB Atlas Vector Search | Managed inside MongoDB | Proprietary feature | HNSW | Yes, with full-text search | Teams already on MongoDB Atlas |
Using a Vector Database in a RAG Pipeline
A vector database sits at the retrieval layer of every retrieval-augmented generation pipeline: the application embeds a query, the vector database finds the nearest stored chunks, and those chunks are injected into the LLM prompt as context. The ingest side runs once per document. A loader pulls source text from object storage, S3, Confluence, or a content management system; a chunker splits each document into 200-to-1,000-token passages with overlap; an embedding model produces a float array for each chunk; and the vector store writes the array, the chunk text, and metadata such as source URL and updated_at. Pinecone's test-at-scale guide shows the bulk path for that ingest, where the import feature loads millions of vectors from object storage in parallel rather than streaming them one at a time (Pinecone, test at scale). The query side runs every time a user asks something. The application embeds the query, calls the vector DB for the top-k nearest chunks, optionally reranks them with a cross-encoder, formats the chunks into the prompt template, and sends the assembled prompt to the LLM. For the full retrieval pattern and its trade-offs, see RAG pipeline architecture and chunk retrieval mechanics.
- Chunk: split each source document into overlapping passages sized to the embedding model's input limit.
- Embed: send each chunk to an embedding model and store the returned float array alongside the chunk text and metadata.
- Index: insert each vector into the vector database, which builds or updates its HNSW or IVF structure on write.
- Retrieve: at query time, embed the user query and ask the vector store for the top-k nearest chunks with metadata filters applied.
- Augment: format the retrieved chunks into the LLM prompt as grounding context and send the assembled prompt to the model.
When a Dedicated Vector Database Is Not Necessary
A vector database as a separate service is not always the right choice: several general-purpose databases now expose native vector columns that cover the typical RAG use case without an extra infrastructure component. PostgreSQL with the pgvector extension stores embeddings as a vector column and supports HNSW and IVFFlat indexes inside ordinary SQL queries, which keeps similarity search next to the application's existing tables and joins. MongoDB Atlas Vector Search lets teams search and index vector data alongside other MongoDB data and combine similarity search with full-text search and field filtering, per the official documentation (MongoDB, Vector Search overview). On the Microsoft side, EF Core 10 introduced vector support, and Microsoft documents that it is only supported with SQL Server 2025 and above, with the SQL Server vector data type storing embeddings for semantic search and RAG workloads (Microsoft, EF Core vector search on SQL Server). The trade-off is real but bounded.
- Embedding corpus under 10 million vectors: pgvector, MongoDB Atlas Vector Search, or SQL Server 2025 vector columns usually keep up.
- Strong relational or document constraints: staying inside the existing database avoids two-system consistency and a second operational surface.
- Dedicated vector database earns its place when: the corpus exceeds tens of millions of vectors, hybrid search latency becomes a bottleneck, or filter cardinality stresses the general-purpose engine.
- FAISS as a library: a custom service can embed FAISS directly and skip both the dedicated vector DB and the general-purpose database for the smallest, simplest deployments.
References
- Pinecone, LangChain integration
- Pinecone, test at scale
- Pinecone, generate-embeddings reference
- Weaviate documentation
- Weaviate, query tutorial
- Weaviate, Weaviate Embeddings model provider
- MongoDB, Vector Search overview
- Microsoft, EF Core vector search on SQL Server
Further reading
Frequently Asked Questions
What is the difference between a vector database and a traditional database?
A vector database retrieves data by measuring geometric distance between high-dimensional embeddings rather than matching exact column values. A traditional relational database filters rows by equality or range predicates on structured fields; it has no native concept of similarity between floating-point arrays. Vector databases add ANN index structures like HNSW or IVF that make approximate nearest-neighbor queries fast at scale, which SQL databases were not designed to do.
What is HNSW and why do vector databases use it?
HNSW (Hierarchical Navigable Small World) is an ANN index structure that organizes vectors as a layered graph. Queries skip most of the dataset and find approximate nearest neighbors in sub-linear time. Vector databases use HNSW because brute-force comparison across millions of vectors is too slow for real-time retrieval, and HNSW delivers the best recall-versus-latency trade-off of the common index types.
Can I use MongoDB or PostgreSQL instead of a dedicated vector database?
Yes for many RAG workloads. MongoDB Atlas Vector Search lets you store and query embeddings inside your existing MongoDB collections per the official documentation. PostgreSQL with the pgvector extension and SQL Server 2025 with EF Core 10 also support vector columns and HNSW indexing. A dedicated vector database adds value mainly when the embedding corpus exceeds tens of millions of vectors or when advanced filtering and hybrid search performance becomes a bottleneck.
What is hybrid search in a vector database?
Hybrid search in a vector database combines dense vector similarity scoring with sparse keyword scoring (typically BM25) in a single query. Weaviate documents this combination as querying with both semantic and lexical methods simultaneously. Hybrid search improves retrieval precision when the query contains specific product names, codes, or proper nouns that pure semantic search can miss.
How does a vector database fit into a RAG pipeline?
A vector database stores the pre-computed embeddings of your document chunks and answers similarity queries at inference time. When a user submits a query, the application converts it to an embedding, sends that vector to the vector database, and receives the top-k most similar chunks; those chunks are appended to the LLM prompt as grounding context, reducing hallucination by anchoring the model to retrieved text.









