---
title: "Vector database"
type: "glossary term"
url: "https://aifordevs.org/glossary#vector-database"
markdown: "https://aifordevs.org/glossary/vector-database.md"
publisher: "AI for Devs"
license: "https://aifordevs.org/reuse"
attribution: "Credit AI for Devs and link to https://aifordevs.org/glossary#vector-database"
---

# Vector database

A vector database is a database that indexes embeddings and returns the nearest neighbors to a query vector, usually with approximate search such as HNSW. It is a common retrieval layer in RAG systems.

Approximate indexes trade some recall for speed, and you tune that trade with parameters such as ef_search. pgvector runs exact search by default and switches to approximate search when you add an HNSW or IVFFlat index. Metadata filters interact with the index, so measure recall with your real filters on.

## Example

pgvector's HNSW index accepts vector columns of up to 2,000 dimensions, so a 3,072-dimension text-embedding-3-large vector must be shortened or stored as halfvec.

## Source

[pgvector on GitHub](https://github.com/pgvector/pgvector)

## Related terms

- [Embedding](https://aifordevs.org/glossary#embedding)
- [RAG](https://aifordevs.org/glossary#rag)
- [HNSW](https://aifordevs.org/glossary#hnsw)
- [Hybrid search](https://aifordevs.org/glossary#hybrid-search)
- [Reranking](https://aifordevs.org/glossary#reranking)
- [Chunking](https://aifordevs.org/glossary#chunking)

## Read the article

[What is a vector database? HNSW, IVF, and when to skip one](https://aifordevs.org/articles/what-is-a-vector-database)

## Cite this term

AI for Devs. "Vector database." https://aifordevs.org/glossary#vector-database

- Page: https://aifordevs.org/glossary#vector-database
- Markdown: https://aifordevs.org/glossary/vector-database.md
- Reuse: Quote or summarize with a link to this page. Terms: https://aifordevs.org/reuse
- Publisher: AI for Devs
