Category leaders

Guide

What Is a Vector Database?

A plain-English guide to vector databases: what they are, what embeddings and vector embeddings are, how similarity search and approximate nearest neighbour indexes such as HNSW and IVF work, how vector databases power RAG and semantic search, whether you need a dedicated one or the vector search in a database you already run, where they fail, and a short history.

November 17, 2026 · The AI Rankings

Quick answer: A vector database is a database built to store embeddings, which are lists of numbers that represent the meaning of text, images or audio, and to find the stored items whose numbers are closest to a query’s. That lets software search by meaning rather than by exact words, so a search for “how do I cancel” can find a document that only says “terminating your subscription”. Vector databases are the storage and search layer behind retrieval-augmented generation (RAG), semantic search and recommendation systems. The one caveat: you often do not need a separate product, because PostgreSQL, Elasticsearch, OpenSearch, Redis and MongoDB all offer vector search inside the database you may already run.

Definition: A vector database stores data as vectors, fixed-length lists of numbers produced by an embedding model, and retrieves the items most similar to a query vector. Items with similar meaning sit close together in that numerical space, so “closest vectors” means “most related content”. Special indexes make that search fast across millions or billions of items.

This page is the explainer: what vector databases and embeddings are, how they work and when you need one. It does not rank products. For the ranked, priced comparison of Qdrant, pgvector, Pinecone, Milvus, Weaviate and the rest, see best vector databases. For the models that create the vectors, see best embedding models. For the architecture a vector database usually sits inside, see what is RAG. For one-line definitions of the surrounding vocabulary, see the AI glossary.


What is a vector database?

A vector database is a system that stores vectors alongside the data they describe and answers one main question very quickly: which stored vectors are nearest to this one?

A vector, in this context, is an ordered list of numbers such as [0.12, -0.48, 0.91, ...]. AI systems create vectors with an embedding model, which reads a sentence, a product description, a photo or a clip of audio and outputs a list of a few hundred to a few thousand numbers. The model is trained so that items with similar meaning get similar lists of numbers. Each list is a point in a space with hundreds or thousands of dimensions, and related items land near each other.

A vector database then does three jobs:

  1. Stores each vector with an ID, the original content or a pointer to it, and metadata such as author, date or access permissions.
  2. Indexes the vectors so that nearest-neighbour search does not have to compare the query against every stored item.
  3. Queries by taking a new vector, usually the embedded version of a user’s question, and returning the closest matches, often filtered by metadata.

Vector database vs traditional database

Traditional relational databaseVector database
StoresRows and columns of exact valuesVectors (lists of numbers) plus metadata
Typical query”Find orders where customer_id = 4821""Find the 10 passages most similar in meaning to this question”
Match typeExact match, ranges, joinsSimilarity: nearest neighbours by distance
AnswerCorrect or emptyRanked by closeness, usually approximate
IndexB-tree, hashHNSW graph, IVF clusters, quantised codes
Good forTransactions, reporting, recordsSemantic search, RAG, recommendations, deduplication

A keyword search engine sits between the two. It finds documents that share words with the query, ranked by measures such as BM25. It works well for names, product codes and error strings, and poorly when the query and the document use different words for the same thing. Vector search has the opposite profile, which is why many systems combine the two (see hybrid search below).

These terms are often used interchangeably, and the difference matters when choosing a tool.

TermWhat it isExamples
Vector indexThe data structure that makes nearest-neighbour search fastHNSW, IVF, DiskANN
Vector search libraryCode that builds and searches an index in memory, with no server, persistence or access controlFaiss from Meta, hnswlib
Dedicated vector databaseA full database built around vector search: storage, durability, filtering, scaling, APIsQdrant, Milvus, Weaviate, Pinecone, Chroma
Vector search in an existing databaseVector types and indexes added to a general-purpose databasepgvector for PostgreSQL, Elasticsearch, OpenSearch, Redis, MongoDB

Some dedicated vector databases are built on these libraries: Milvus’s search engine, Knowhere, incorporates Faiss, hnswlib and Annoy (Milvus). A library on its own is not a database: it does not save data safely, filter by permissions or serve many users at once.


What is an embedding?

An embedding is a list of numbers that represents a piece of content, positioned so that content with similar meaning has similar numbers. Embeddings are what a vector database stores.

An embedding model creates them. You give it a chunk of text, an image or a sound, and it returns a vector with a fixed number of dimensions. Two examples of output sizes, from the providers’ own documentation:

No single number means anything on its own. The meaning is in the position of the whole vector relative to others. Two support tickets about refunds will sit close together; a ticket about a refund and a recipe for bread will sit far apart.

What are vector embeddings?

“Vector embeddings” and “embeddings” mean the same thing: the vector is the list of numbers, and “embedding” describes how the content has been placed (embedded) in a mathematical space.

Google’s 2013 word2vec paper describes the classic illustration. Word vectors learned from large amounts of text captured relationships as directions: the vector for “king”, minus “man”, plus “woman” landed closest to the vector for “queen”. Modern embedding models work on whole sentences, paragraphs, images and audio rather than single words, but the principle is the same: distance in the space tracks difference in meaning.

ContentWhat an embedding capturesTypical use
Text passageTopic, intent and meaning, beyond the exact wordsRAG, semantic search, support ticket routing
Search queryWhat the person is looking forMatching queries to documents
ImageObjects, scene, styleVisual search, finding near-duplicate photos
Product or userPreferences and attributes learned from behaviourRecommendations
CodeWhat a function doesCode search in AI coding tools
AudioSpeech content or sound characteristicsFinding similar clips, voice matching

Where embeddings come from

Embedding models are neural networks, often built on the same transformer architecture as large language models, trained so that matching pairs (a question and its answer, a caption and its image) end up close together and unrelated pairs end up far apart. They are cheap to run compared with chat models. OpenAI’s documentation puts text-embedding-3-small at about 62,500 pages per dollar, assuming about 800 tokens a page, so embedding a 500-page book costs less than a cent.

Three practical points follow from how embeddings work:

How much space vectors take

A vector stored at full precision (32-bit floating point) takes 4 bytes per dimension. That adds up fast at scale.

VectorBytes each1 million vectors100 million vectors
3,072 dimensions, float3212,28812.3 GB1,229 GB
1,536 dimensions, float326,1446.1 GB614 GB
1,024 dimensions, float324,0964.1 GB410 GB
1,024 dimensions, int81,0241.0 GB102 GB
1,024 dimensions, binary1280.13 GB12.8 GB

The usual fix is quantisation: storing each number with fewer bits. In tests by Hugging Face and mixedbread on the MTEB retrieval tasks, int8 vectors took 4 times less memory and binary vectors 32 times less. With a rescoring step against the full-precision vectors, int8 kept about 99% of retrieval performance and binary about 96%.


How does a vector database work?

Every vector database follows the same basic flow.

StageWhat happens
1. EmbedEach document, chunk, image or product is turned into a vector by an embedding model
2. InsertThe vector is stored with its ID, original content or a link to it, and metadata
3. IndexThe database organises vectors into a structure (a graph, clusters or compressed codes) built for fast nearest-neighbour search
4. QueryA new input, such as a user’s question, is embedded with the same model
5. SearchThe index is searched for the vectors closest to the query vector, with any metadata filters applied
6. ReturnThe top matches come back ranked by similarity score, usually with their original content

In a RAG system, those returned passages are then pasted into a language model’s prompt so it can answer from them. The RAG guide covers the stages either side of the database: chunking, reranking and generation.

Measuring similarity: cosine, dot product and Euclidean distance

“Closest” needs a definition. Vector databases use a distance or similarity metric, chosen when the index is created.

MetricWhat it measuresNotes
Cosine similarityThe angle between two vectors, ignoring their lengthRanges from -1 (opposite) to 1 (same direction). OpenAI’s embeddings guide uses it
Dot product (inner product)Angle and length combinedGives the same ranking as cosine when vectors are normalised to length 1, and is slightly cheaper to compute
Euclidean distance (L2)Straight-line distance between two pointsAlso gives the same ranking as cosine when vectors are normalised to length 1
Hamming distanceNumber of differing bitsUsed with binary-quantised vectors

The right metric is the one the embedding model was trained for, which its documentation usually states. Using a different one degrades results without any error message.

Why exact search is too slow

The simplest search compares the query vector with every stored vector and keeps the closest. This is called flat or brute-force search, and it is perfectly accurate. It is also slow at scale: 10 million vectors of 1,536 dimensions means around 15 billion multiplications for every single query.

Vector databases solve this with approximate nearest neighbour (ANN) search. An ANN index finds most of the true nearest neighbours while checking only a small fraction of the collection. The trade-off is measured as recall: the share of the true top results that the index actually returns. A recall of 0.95 at 10 means the index found, on average, 9.5 of the real 10 nearest vectors. Every ANN index lets you trade recall for speed, and a benchmark result means nothing without its recall figure.

The main index types

IndexHow it worksStrengthsWeaknesses
FlatCompares against every vectorExact results, no build timeGets slower in direct proportion to the size of the collection
IVF (inverted file)Groups vectors into clusters; a query searches only the nearest few clustersFaster to build and uses less memory than HNSWLower recall at the same speed; the clusters are learned from the data, so they can drift as the data changes
HNSW (hierarchical navigable small world)Builds a layered graph linking each vector to its neighbours; a query hops through the graph from coarse to fine layersHigh recall at high speedSlower to build and uses more memory than IVF
DiskANN and similarA graph designed to live mostly on SSD rather than in RAMMicrosoft’s DiskANN paper searched a billion vectors on one workstation with 64GB of RAM and an SSDHigher latency than an in-memory graph
Quantisation (scalar, binary, product)Compresses vectors into short codes, often combined with IVF or HNSWint8 cuts memory by 4 times and binary by 32 timesSome accuracy loss, usually recovered by rescoring with full vectors

The IVF and HNSW trade-offs above are as pgvector’s documentation states them: HNSW “has better query performance than IVFFlat (in terms of speed-recall tradeoff), but has slower build times and uses more memory” (pgvector).

HNSW comes from a 2016 paper by Yury Malkov and Dmitry Yashunin. pgvector, Qdrant, Weaviate, Milvus, Redis, Elasticsearch and OpenSearch all support it.

Real queries rarely want only “the most similar items”. They want the most similar items that this user is allowed to see, from the last year, in English. That is filtered vector search, and it is one of the main things a vector database does that a bare library does not. Filtering after the search can leave too few results, and filtering before it can slow a graph index, so systems differ in how they combine the two.

Hybrid search combines vector search with keyword search (usually BM25) and merges the two ranked lists, often with a method called reciprocal rank fusion. Vector search finds passages that mean the same thing in different words; keyword search catches exact names, codes and error messages that embeddings tend to blur. Weaviate, Elasticsearch and OpenSearch are among the systems that offer it as a built-in query.


What are vector databases used for?

UseHow the vector database is used
RAG for chatbots and assistantsStores chunks of company documents; retrieves the passages relevant to each question so a language model can answer from them
Semantic searchMatches queries to documents, products or help articles by meaning rather than keywords
RecommendationsFinds products, songs, videos or articles near the ones a user liked
Image and multimodal searchFinds visually similar images, or images that match a text description
Deduplication and clusteringSpots near-duplicate documents, tickets or records that are worded differently
Agent memoryStores past conversations, notes and tool results so an AI agent can recall relevant context later
Anomaly and fraud detectionFlags items that sit far from any normal cluster
Code searchFinds functions by what they do, inside AI coding tools and code hosts

Vector databases and RAG

A language model only knows what was in its training data. RAG gives it access to private, recent or specialist information by retrieving relevant passages at question time and placing them in the prompt.

The vector database is the retrieval step. Documents are split into chunks, each chunk is embedded and stored, and every question is embedded and matched against the store. The quality of the answer is capped by the quality of that retrieval: if the right passage is not returned, the model cannot use it. The RAG guide covers the whole pipeline, including when long context windows or agentic search replace a vector lookup.

You do not always see the database. OpenAI’s file search and Google’s Gemini API File Search store and search vectors for you behind a simple upload, and Amazon Bedrock Knowledge Bases and Pinecone Assistant offer the same on their platforms.

Is the vector database being replaced?

For code, in some tools. Anthropic’s Boris Cherny said in May 2025 that early versions of Claude Code used RAG and that the team settled on agentic search, in which the agent runs file-search commands itself, because “it outperformed everything else by a lot” (OfficeChai). Cursor reported the opposite result for its own coding agent: adding semantic search gave 12.5% higher accuracy in answering questions on average, by Cursor’s own measurement (Cursor). For large collections of documents, images and products, vector search is usually one tool among several (vector, keyword and metadata search) that a system or agent can choose between. The RAG guide sets out both sides.


Do you need a vector database?

Often not a separate one. Vector search is a feature of most major databases, and the right starting point depends on what you already run.

OptionWhat it isExamplesBest when
Vector search in a database you already runVector types and indexes added to your existing databasepgvector (PostgreSQL), Elasticsearch, OpenSearch, Redis, MongoDBSearch is one feature of your product, and one system to operate matters more than peak performance
Dedicated open-source vector databaseA purpose-built engine you host yourselfQdrant, Milvus, Weaviate, Chroma, Vespa, LanceDBRetrieval is central, you want control, and you can run the infrastructure
Managed vector databaseA dedicated engine run for you as a cloud servicePinecone, Zilliz Cloud, Qdrant Cloud, Weaviate CloudRetrieval is central and you have no platform team to spare
Object-storage-based retrievalVectors kept on cheap cloud storage, with compute only when queriedAmazon S3 Vectors, turbopufferVery large collections, many tenants, or infrequent queries
Managed RAG serviceUpload files; the provider handles embedding, storage and searchOpenAI file search, Gemini API File Search, Amazon Bedrock Knowledge BasesYou want a working retrieval system without building one

A few rules of thumb:

The ranked comparison, with each system’s pricing, licence and benchmark record, is on our best vector databases page, linked at the top of this guide.


Examples of vector databases

This is a reference list by type, not a ranking.

SystemTypeLicenceNotes
pgvectorPostgreSQL extensionPostgreSQL LicenceAdds vector search to PostgreSQL; HNSW and IVFFlat indexes
QdrantDedicatedApache 2.0Written in Rust; self-hosted or managed cloud
Milvus / Zilliz CloudDedicatedApache 2.0Built for very large collections; Zilliz runs the managed version
WeaviateDedicatedBSD-3-ClauseHybrid keyword and vector search built in
PineconeManaged onlyProprietaryFully managed service; no self-hosted option
ChromaDedicatedApache 2.0Open source, with a managed Chroma Cloud
Elasticsearch / OpenSearchSearch engineElastic: AGPLv3, SSPL or ELv2; OpenSearch: Apache 2.0Vector search alongside full keyword search
RedisIn-memory databaseRSALv2, SSPLv1 or AGPLv3 (Redis 8 and later)Keeps indexes in memory, for low latency
MongoDB Vector SearchDocument databaseSource-available (SSPL)Vector search in MongoDB Atlas and, since 30 June 2026, generally available in self-managed Community and Enterprise Advanced deployments (MongoDB)
Amazon S3 VectorsObject storageProprietaryVectors stored directly in S3; generally available since 2 December 2025 (AWS)
LanceDBEmbedded and lakehouseApache 2.0Designed for multimodal data stored as files
FaissLibraryMITMeta’s similarity search library; used inside many other systems

Where vector databases fail

Vector search is powerful and easy to get subtly wrong. The common failure modes:

ProblemWhat goes wrongUsual fix
Exact-term missesA search for a product code, surname or error string returns passages about similar topics but not the exact oneHybrid search with keyword matching
Similar is not relevantThe nearest passage is on the right topic but does not answer the questionA reranker, better chunking, a stronger embedding model
Approximate resultsThe index misses some true nearest neighbours, so the best passage is occasionally skippedTune the index for higher recall; rescore
Embedding lock-inSwitching embedding model means re-embedding and re-indexing everythingChoose the model carefully; plan for re-indexing
Stale dataDocuments change but their vectors do notRe-embed on update; delete old vectors
Tight filtersStrict metadata filters make queries slow or return too few resultsA system with filter-aware indexing
Memory costFull-precision vectors at scale need large amounts of RAMQuantisation, shorter vectors, disk-based indexes

Security and privacy

Embeddings are not anonymised data. A 2023 study by John Morris and colleagues (EMNLP 2023) recovered 92% of 32-token text inputs exactly from their embeddings, using a method that repeatedly corrects its guess and re-embeds it with the same embedding model.

A vector store should be secured like the documents it was built from: behind authentication, and with permissions, so that a RAG system retrieves only what the person asking is allowed to see. The OWASP Top 10 for LLM Applications lists “vector and embedding weaknesses” as its own risk category.

Benchmarks need care

Many published vector database performance numbers are run by vendors, and they are hard to compare because speed depends on the recall level, hardware, dataset and settings chosen. In one public exchange, Elastic published a benchmark showing a 7 times throughput advantage for Elasticsearch over Qdrant, and Qdrant replied on 8 July 2026 with a 2.1 times advantage for Qdrant at matched recall (Qdrant). On 13 July, Elastic re-ran Qdrant’s setup on identical hardware and found the two systems in the same range at around 0.96 recall (Elastic). The VIBE benchmark, from academic researchers, compares indexing algorithms rather than full databases. When comparing products, check the recall level first: a system that is faster at 0.94 recall has not beaten one at 0.98.


A short history of vector databases

YearEvent
1975Jon Bentley describes the k-d tree, an early structure for nearest-neighbour search in low dimensions
1998Piotr Indyk and Rajeev Motwani publish locality-sensitive hashing, an early approximate method for high dimensions
2011Hervé Jégou, Matthijs Douze and Cordelia Schmid publish product quantisation for nearest-neighbour search, the compression method behind the IVF-PQ indexes in Faiss and several vector databases
2013Google researchers publish word2vec, making learned word embeddings mainstream
2016Yury Malkov and Dmitry Yashunin publish HNSW
2017Facebook AI Research releases Faiss, its open-source library for billion-scale similarity search
2018 to 2019Google researchers publish BERT (2018), and Nils Reimers and Iryna Gurevych adapt it to produce sentence embeddings with Sentence-BERT (2019); Microsoft publishes DiskANN; Zilliz open-sources Milvus and Pinecone is founded
2021pgvector is first released, on 20 April, adding vector search to PostgreSQL
2023pgvector adds HNSW indexes in version 0.5.0 on 28 August; MongoDB makes Atlas Vector Search generally available on 4 December
2025Elasticsearch makes Better Binary Quantization its default for vectors of 384 dimensions or more in version 9.1; Amazon S3 Vectors reaches general availability on 2 December
2026MongoDB Vector Search becomes generally available in self-managed deployments on 30 June; in July, Elastic re-runs Qdrant’s rebuttal of an Elastic benchmark and finds the two systems in the same range


Frequently asked questions

What is a vector database in simple terms?

A vector database is a database that stores data as lists of numbers called vectors, created by an AI embedding model, and finds the items whose numbers are closest to a query’s. Because similar meanings get similar numbers, it can search by meaning instead of exact words. It is the storage and search layer behind many AI chatbots that answer from company documents.

What is a vector database used for?

Vector databases are used for retrieval-augmented generation (RAG), semantic search, recommendations, image search, deduplication and memory for AI agents. In RAG, a vector database finds the passages relevant to a user’s question so a language model can answer from them.

What is an embedding?

An embedding is a list of numbers that represents a piece of text, an image or audio, positioned so that similar content has similar numbers. An embedding model creates it. OpenAI’s text-embedding-3-small, for example, turns any input into 1,536 numbers. Embeddings are what a vector database stores and compares.

What are vector embeddings?

Vector embeddings are the same thing as embeddings: numerical representations of content in which distance tracks difference in meaning. The “vector” is the list of numbers and “embedding” describes how the content is placed in a mathematical space. Two passages about the same topic produce vector embeddings that sit close together.

How does a vector database work?

A vector database stores vectors with their content and metadata, organises them in an index built for fast similarity search, and answers queries by embedding the input with the same model and returning the nearest stored vectors. It uses approximate nearest neighbour indexes, such as HNSW, which find nearly all of the closest matches while checking only a small fraction of the data.

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

A regular relational database finds exact matches, such as every order with a given customer ID. A vector database finds similar items, such as the ten passages closest in meaning to a question, ranked by a similarity score. Many regular databases, including PostgreSQL with the pgvector extension, now do both.

Do I need a vector database for RAG?

You need vector search for most RAG systems, but not necessarily a separate vector database. If your data is already in PostgreSQL, Elasticsearch, OpenSearch, Redis or MongoDB, their built-in vector search is often enough. Managed services such as OpenAI file search handle the vector storage for you. A dedicated vector database pays off at large scale or with heavy filtering needs.

Is pgvector a vector database?

pgvector is an open-source extension that adds vector storage and search to PostgreSQL, rather than a standalone vector database. It supports HNSW and IVFFlat indexes and keeps vectors in the same tables and transactions as the rest of your data.

What is the best vector database?

This guide explains vector databases rather than ranking them. The ranked comparison of Qdrant, pgvector, Pinecone, Milvus, Weaviate and the rest, with prices, licences and benchmark records, is on our best vector databases page, linked at the top of this guide.

What is HNSW?

HNSW, short for hierarchical navigable small world, is a graph-based index for vector search. It links each vector to its nearest neighbours in a layered graph, and a query hops through the layers from coarse to fine to reach the closest matches quickly. It was introduced in a 2016 paper by Yury Malkov and Dmitry Yashunin and is supported by pgvector, Qdrant, Weaviate, Milvus, Redis, Elasticsearch and OpenSearch.

What is cosine similarity?

Cosine similarity measures the angle between two vectors, ignoring their length, on a scale from -1 (opposite) to 1 (pointing the same way). It is a common way to measure how similar two text embeddings are. When vectors are normalised to length 1, cosine similarity gives the same ranking as the dot product, which is cheaper to compute.

No. Semantic search is the task of finding results by meaning; a vector database is one tool for doing it. Semantic search usually works by embedding documents and queries and comparing the vectors, and the vector database stores those vectors and finds the closest matches. Many production systems combine semantic search with keyword search, called hybrid search.

Can text be recovered from embeddings?

Partly, yes. A 2023 study by John Morris and colleagues recovered 92% of 32-token text inputs exactly from their embeddings, using repeated calls to the embedding model that produced them. Embeddings should be treated as being as sensitive as the text they came from, and vector databases secured accordingly.

← All guides