# Vector Database

Canonical: https://aimastermindlab.com/glossary/vector-database

---
A vector database stores and retrieves high-dimensional vector embeddings efficiently. It enables semantic similarity search — finding documents, images, or records that are semantically 'nearest' to a query vector. Examples include Pinecone, Weaviate, Qdrant, and ChromaDB.

## What is a Vector Database?

A vector database is a specialised storage system designed to store, index, and query **dense vector embeddings** at scale. Unlike traditional databases that filter by exact column values, vector databases find records by **approximate nearest neighbour (ANN)** search — identifying which stored vectors are closest to a query vector in high-dimensional space.

## Why Standard Databases Aren't Enough

A SQL database can execute `WHERE price < 100`. But it cannot answer "find me the 10 documents most semantically similar to this query." The similarity calculation across millions of 1536-dimensional vectors requires specialised indexing algorithms.

## Common Indexing Algorithms

- **HNSW (Hierarchical Navigable Small World)** — Graph-based; fast queries, high recall. Used by Qdrant, Weaviate.
- **IVF (Inverted File Index)** — Clusters vectors; scalable to billions. Used by Faiss, Pinecone.
- **ScaNN** — Google's algorithm; excellent for very high-dimensional spaces.

## Popular Vector Databases

| Database | Hosting | Best For |
|---|---|---|
| Pinecone | Managed cloud | Production scale, no ops |
| Weaviate | Self-host / cloud | Hybrid search, rich filtering |
| Qdrant | Self-host / cloud | Performance, Rust-native |
| ChromaDB | Local / self-host | Development, prototyping |
| Milvus | Self-host | Very large-scale |
| pgvector | PostgreSQL extension | Teams already on Postgres |

## Vector DBs vs Traditional DBs

Most vector databases also support hybrid search — combining ANN vector search with traditional keyword (BM25) filters. This is more powerful than either approach alone.

## Example

A RAG chatbot embeds every page of your documentation, stores the vectors in Pinecone, then at query time embeds the user's question and retrieves the 5 nearest document chunks as context for the LLM.
---

Source: https://aimastermindlab.com/glossary/vector-database — AI Mastermind Lab (https://aimastermindlab.com)
