What is a vector database?
A vector database stores embeddings and returns the items closest in meaning to a query. It is the search index behind semantic search in RAG systems.
In short. A vector database is a database that stores embeddings and returns the stored items closest in meaning to a query. An application embeds each document or passage, stores the vectors, and at query time looks up the nearest ones. OpenAI recommends a vector database for searching many embeddings quickly, and RAG systems use one to find passages for a language model.
On this page 6 sections
The evidence
OpenAI recommends a vector database for searching over many vectors quickly, and recommends cosine similarity as the distance function for its embeddings.1
1OpenAI API documentationOpenAI API documentation. Checked Nov 20, 2026.OpenAI's text-embedding-3-small model returns vectors of 1,536 numbers by default, and text-embedding-3-large returns 3,072.1
1OpenAI API documentationOpenAI API documentation. Checked Nov 20, 2026.pgvector runs exact nearest neighbor search by default. Its HNSW and IVFFlat indexes run approximate search, which trades some recall for speed.3
3pgvector (GitHub)pgvector documentation. Checked Nov 20, 2026.In 2019, Microsoft said Bing had turned more than 150 billion pieces of indexed data into vectors, and released its vector search algorithm, SPTAG, as open source.5
5Microsoft SourceMicrosoft, May 15, 2019.Vector databases let AI search find passages by meaning, so a page can match a question even when it shares no words with it. Microsoft said in May 2019 that Bing had turned more than 150 billion pieces of indexed data into vectors.
A vector database stores embeddings, the lists of numbers that represent the meaning of a piece of text, and finds the stored items closest to a query. It is the index behind semantic search. Texts with similar meanings have vectors that sit close together, so the nearest vectors to a query belong to the most similar texts.
#How a vector database works
A vector search runs in two stages. First, an embedding model turns each document or passage into a vector, and the database stores it. OpenAI's embeddings guide says its text-embedding-3-small model returns 1,536 numbers per text by default, and text-embedding-3-large returns 3,072. At query time, the application embeds the query with the same model and asks the database for the closest stored vectors.1
Closeness is measured with a distance function. OpenAI recommends cosine similarity. Its embeddings are normalized to length 1, so cosine similarity and Euclidean distance give the same ranking. For searching over many vectors quickly, OpenAI recommends a vector database.1
#Exact and approximate search
An exact search compares the query with every stored vector. The pgvector documentation says the PostgreSQL extension does this by default, which gives perfect recall. Adding an HNSW or IVFFlat index switches to approximate nearest neighbor search, which trades some recall for speed. Results can then differ from those before the index was added.3
HNSW comes from a 2016 paper on Hierarchical Navigable Small World graphs. It builds layers of proximity graphs over the stored vectors and starts each search from the top layer, which the authors say allows logarithmic complexity scaling.4
#Vector databases in AI search
Retrieval-augmented generation uses a vector database to find passages for a model. Anthropic's post on Contextual Retrieval describes the steps: split documents into chunks, embed each chunk, store the embeddings in a vector database, and at query time add the most similar chunks to the prompt.6 OpenAI's retrieval guide calls its vector stores the containers that power semantic search for its file search tool.2
Web search engines use vector search at a larger scale. In May 2019, Microsoft said Bing had turned more than 150 billion pieces of indexed data into vectors, including words, page snippets and full queries. It released SPTAG, the algorithm Bing uses to search them, as open source.5
Anthropic's pipeline combines embedding search with BM25 keyword search, which finds chunks by exact matches.6 pgvector supports the same kind of hybrid search by pairing vector search with PostgreSQL full-text search.3 What is semantic search? covers hybrid search, and What are vector embeddings? covers dimensions and similarity measures.
A search engine can only embed a page it has crawled and indexed. How Google crawls and indexes pages covers that step.
Read next
LLMs
What are vector embeddings?
A vector embedding is a list of numbers that represents the meaning of text. OpenAI's text-embedding-3-large returns 3,072 of them by default.
AI search
What is semantic search and how does it differ from keyword search?
Semantic search matches the meaning of a query, often with vector embeddings. Keyword search matches its words. Hybrid search runs both and merges the results.
AI search
What is retrieval-augmented generation (RAG)?
RAG retrieves documents at query time and gives them to a language model to write a cited answer. How ChatGPT, Claude, Google, Bing and Perplexity use it.
Crawlers
How Google crawls and indexes pages
Crawling and indexing are separate steps, and Google guarantees neither. How each works, how to find where a page failed and how to audit crawl efficiency.
Questions
What is the difference between a vector database and a regular database?
A regular database finds rows whose values match a condition, such as a product ID. A vector database finds the stored vectors closest to a query vector, which returns items similar in meaning to the query even when they share no words with it. Some regular databases add vector search, for example PostgreSQL with the pgvector extension.
Do I need a vector database for RAG?
Not for a small collection. OpenAI's examples compare a query embedding with every stored embedding directly. For searching many vectors quickly, OpenAI recommends a vector database, and Anthropic includes one in its description of a RAG pipeline.
What is approximate nearest neighbor search?
It is a search that returns vectors close to the query without checking every stored vector. It trades some recall for speed, so it can miss some of the true nearest neighbors. HNSW, a graph-based method published in 2016, is one such index, and pgvector supports it.
Notes
- 1
- 2
- 3
- 4
- 5
- 6
About this page
Researched and reviewed by Promptly Found. Reviewed Nov 20, 2026. Next review due Feb 2027.
Cite this page
Promptly Found. (2026, November 20). What is a vector database? https://promptlyfound.com/glossary/vector-database
Revisions 1
- First published.