# Vector database

> A vector database is a data store built to save embeddings, the numeric representations of text, images or audio, and to find the stored items most similar in meaning to a query, which makes it the usual search layer behind RAG systems.

Also called: vector store, vector DB, vector index, embedding database. Category: Data and retrieval. Source: https://aibuildindex.com/glossary/vector-database

## In the index

- Vector databases: median $4,000, middle half $500 to $11,400, 264 priced briefs (https://aibuildindex.com/skills/vector-databases)
- Pinecone: median $3,600, middle half $440 to $7,200, 72 priced briefs (https://aibuildindex.com/tools/pinecone)
- Search over internal documents: median $2,150, middle half $300 to $8,800, 918 priced briefs (https://aibuildindex.com/cost/document-search-rag)

Ordinary databases are good at exact matches: find the order with this number, the customer with this email. A vector database answers a different question: which stored items are closest in meaning to this one? It does that by storing [embeddings](https://aibuildindex.com/glossary/embedding), lists of numbers that place similar content near each other, and searching them quickly. Almost every system that lets a language model answer from company documents uses one, so the choice of vector database is a common line in AI build quotes.

## How it works

Content is first split into passages and converted to embeddings by an embedding model. Each embedding is stored with an ID, the original text and metadata such as source, date or the users allowed to see it. At query time, the question is embedded with the same model and the database returns the nearest stored vectors, usually measured by cosine similarity.

Searching millions of vectors one by one would be slow, so vector databases build approximate nearest-neighbour indexes, such as HNSW, that trade a small amount of accuracy for large gains in speed. Most also support metadata filters ("only documents for this customer account"), which is how [access control](https://aibuildindex.com/glossary/access-control) is enforced in retrieval.

Options range from dedicated managed services such as [Pinecone](https://aibuildindex.com/glossary/pinecone), Weaviate and Qdrant to vector extensions on existing databases, notably pgvector for PostgreSQL, which is available on platforms like Supabase. For small collections even an in-memory index can be enough.

## What it means for cost

The vector database is rarely the largest cost in a [retrieval-augmented generation](https://aibuildindex.com/glossary/retrieval-augmented-generation) build, but the choice affects running costs and maintenance:

- **Managed or self-hosted.** A managed service is quicker to start and bills by storage and queries; self-hosting avoids that bill but adds operations work.
- **Existing stack.** If the business already runs PostgreSQL, adding pgvector can avoid a new vendor entirely.
- **Volume and freshness.** Large collections and frequently changing documents raise storage, indexing and re-embedding costs.

Ask a builder why they chose a given store, how the index is updated when documents change, and what it would take to move to another one later. Live figures for retrieval builds are on the [document search and RAG cost page](https://aibuildindex.com/cost/document-search-rag).

## Common questions

### Does every RAG build need a dedicated vector database?

Often not at small or moderate scale. PostgreSQL with pgvector, or the vector features in many existing databases, handles a great many business use cases. A dedicated service becomes attractive with very large collections, heavy query traffic or a wish to avoid running database infrastructure.

### Can a vector database replace keyword search?

Not entirely. Vector search is good at meaning but can miss exact terms such as product codes or names. Many production systems combine both in [hybrid search](https://aibuildindex.com/glossary/hybrid-search).

## Related terms

- [Embedding](https://aibuildindex.com/glossary/embedding): An embedding is a list of numbers that represents the meaning of a piece of text, an image or another item, so that items with similar meanings end up close together and can be compared, searched or grouped by software.
- [Retrieval-augmented generation (RAG)](https://aibuildindex.com/glossary/retrieval-augmented-generation): Retrieval-augmented generation is a way of answering questions with a language model that first looks up relevant passages in your own documents, then writes an answer grounded in what it found.
- [Semantic search](https://aibuildindex.com/glossary/semantic-search): Semantic search is search that matches by meaning rather than exact words, typically by comparing embeddings, so a query such as "how do I get my money back" can find a page titled "Refund policy".
- [Hybrid search](https://aibuildindex.com/glossary/hybrid-search): Hybrid search combines keyword search and semantic vector search in one query and merges their results, so a system finds both exact matches such as product codes and passages that match by meaning.
- [Chunking](https://aibuildindex.com/glossary/chunking): Chunking is the step in a retrieval system that splits long documents into smaller passages before they are embedded and indexed, so that a search can return the specific section that answers a question rather than a whole file.
- [Pinecone](https://aibuildindex.com/glossary/pinecone): Pinecone is a fully managed vector database service that stores embeddings and returns the most similar items to a query, commonly used as the search layer in retrieval-augmented generation and semantic search builds.
