Glossary · V

Vector Database

Database that stores embeddings as high-dimensional vectors and retrieves the most similar items through fast nearest-neighbor search.

By Obseria TeamUpdated

Definition

A vector database is a data store optimized for embeddings, numerical vectors that represent the meaning of text, images or other data. It indexes these vectors and answers similarity queries, returning the items closest to a query vector by measures such as cosine similarity. Vector databases are a core component of semantic search and retrieval-augmented generation.

What is a vector database?

A vector database stores data as vectors and finds entries by similarity instead of exact matches. The vectors are embeddings: an embedding model turns a sentence, a document chunk or an image into a list of hundreds or thousands of numbers, positioned so that semantically similar content lies close together. A query such as "how do I reset my password" is embedded the same way, and the database returns the stored chunks whose vectors are nearest, even if they use different words.

This makes vector databases the retrieval layer of most retrieval-augmented generation (RAG) systems, where relevant documents are fetched and placed into the model's context window. They are also used for semantic search, recommendations, deduplication and anomaly detection.

How a vector database works

  1. Ingestion: documents are split into chunks, each chunk is embedded, and the vector is stored together with the original text and metadata such as source, tenant or date.
  2. Indexing: the database builds an index that makes similarity search fast.
  3. Query: the query is embedded with the same model, and the database returns the top k nearest vectors, optionally filtered by metadata.
  4. Re-ranking (optional): a second model re-orders the candidates by relevance before they are passed to the LLM.

Similarity is measured with a distance metric, most often cosine similarity, dot product or Euclidean distance. The metric must match the one the embedding model was trained for.

Indexes and approximate nearest neighbor search

Comparing a query with every stored vector (exact or brute-force search) is accurate but slows down as the collection grows. Vector databases therefore use approximate nearest neighbor (ANN) indexes that trade a small loss in recall for much lower latency:

  • HNSW (Hierarchical Navigable Small World): a multi-layer graph that is navigated from coarse to fine. Fast and accurate, but memory-intensive.
  • IVF (inverted file): vectors are grouped into clusters, and only the nearest clusters are searched.
  • Quantization, for example product quantization: vectors are compressed to reduce memory, at some cost in precision.

Index parameters such as the number of candidates examined per query directly control the balance between recall, latency and memory.

Dedicated vector databases and extensions

There are two broad options. Dedicated vector databases are built specifically for vector search and its scaling. Alternatively, many existing systems have added vector support, for example the open-source pgvector extension for PostgreSQL, vector search in Redis, or vector fields in search engines and document databases. An extension is often enough when the data already lives in that system and the collection size is moderate; dedicated systems become attractive for very large collections or demanding latency targets. Hybrid search, which combines vector similarity with classic keyword search, often improves results for exact terms such as product numbers or error codes.

Monitoring a vector database

A slow or poorly tuned vector store degrades every RAG answer. Useful signals:

  • Query latency as percentiles (p95, p99), separated by collection and filter.
  • Retrieval quality: recall against a labeled test set, and how often retrieved chunks are actually used or cited.
  • Index health: memory usage, index build and rebuild times, vector count per collection.
  • Ingestion lag: how long new or changed documents take to become searchable.
  • Embedding calls: latency, errors and cost of the embedding model.

Because the same chunk can be returned for many queries, tracing the retrieval span together with the LLM call shows whether a wrong answer was caused by retrieval or by the model.

Common problems in practice

Many retrieval issues are not caused by the database itself. Poor chunking splits answers across fragments or mixes unrelated topics in one chunk. Changing the embedding model without re-embedding all documents makes old and new vectors incomparable. Missing metadata filters let one tenant's documents appear in another tenant's results, which is a security problem, not only a quality problem. Stale indexes return outdated content after documents were changed or deleted. Each of these shows up as worse answers, so it pays to log which chunks were retrieved for a request, with their scores and source, and to keep that information next to the answer.

How Obseria helps

Obseria traces RAG pipelines end to end with OpenTelemetry: embedding call, vector query and LLM call appear as spans in one trace, so AI observability shows where time and tokens go. Database monitoring covers backends such as PostgreSQL with pgvector or Redis.

Frequently asked questions

A relational database finds rows by exact values and joins. A vector database finds entries by similarity of embeddings. Many relational databases now add vector search through extensions such as pgvector for PostgreSQL.

You need some form of retrieval. A vector database or vector extension is the most common choice, but keyword search, hybrid search or a small in-memory index can be enough for small or highly structured document sets.

HNSW (Hierarchical Navigable Small World) is a graph-based approximate nearest neighbor index. It is widely used because it offers high recall at low latency, at the cost of higher memory consumption.

Query latency percentiles, retrieval recall on a test set, memory and index size, ingestion lag and error rate. Correlate them with the LLM calls that use the retrieved results.

Put these concepts into practice

Try Obseria free for 14 days, with OpenTelemetry and no proprietary agents.