Skip to content
Devgo

Vector database

A database optimized for storing and searching embeddings (vectors) by similarity. Vector DBs find the 'nearest neighbors' — most similar items — in milliseconds. Used for RAG, semantic search, and recommendations. Examples: Pinecone, pgvector, Weaviate, Qdrant.

When to use
  • RAG (retrieve docs for LLMs).
  • Semantic search.
  • Recommendation systems.
  • Deduplication by similarity.
When not to
  • Exact keyword search (use full-text search).
  • Small datasets (scan is fine).
  • When you need ACID transactions.

Definition

A stores vectors (embeddings) with metadata and supports nearest-neighbor search — find the k most similar vectors to a query. Uses ANN (approximate nearest neighbor) algorithms (HNSW, IVF) for fast search at scale. Often adds filtering by metadata.

Why it exists

Standard databases can't efficiently search by semantic similarity. Vector DBs use specialized indexes (HNSW, IVF) to find similar vectors in milliseconds even with millions of items.

How it works

Insert: embed your data, store the vector + metadata. Query: embed the query, the DB finds nearest neighbors by cosine/L2 distance using an ANN (HNSW graph, IVF clusters). Returns similar items with scores. Filter by metadata (e.g., category, date).

Scaling limits

ANN is approximate (recall vs speed tradeoff). build time. Memory usage (HNSW is memory-heavy). Sharding for very large scale. Cost of managed services.

Cost shape

Self-hosted (pgvector, Qdrant — free). Managed (Pinecone, Weaviate Cloud — pay per usage/storage).

Alternatives

  • pgvector (PostgreSQL extension) — + vectors in one DB, simpler, less specialized.
  • Full-text search (Elasticsearch) — Keyword search, no semantic similarity.

Failure modes

  • Recall/speed tradeoff tuning.
  • memory usage.
  • Stale vectors.
  • Poor quality.

,