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.

Related terms

  • Embedding An embedding is a numerical vector representation of data (text, image, audio) that captures semantic meaning. Similar concepts have embeddings that are close together in vector space, enabling AI systems to measure similarity, cluster data, and retrieve relevant information.
  • RAG (Retrieval-Augmented Generation) RAG is a technique that combines an LLM with an external knowledge retrieval system. Instead of relying solely on its training data, the model retrieves relevant documents at query time and uses them as context to generate more accurate, up-to-date responses.
  • Semantic Search Semantic search retrieves results based on the meaning of a query rather than exact keyword matches. Using vector embeddings, it finds content that is conceptually related to the query, even when no words overlap — solving the vocabulary mismatch problem in traditional search.
  • Cosine Similarity Cosine similarity measures the angle between two vectors in high-dimensional space. In AI, it quantifies how semantically similar two embeddings are — a score of 1.0 means identical direction (highly similar), 0 means orthogonal (unrelated), -1 means opposite meaning.