Vector Database

A vector database stores embeddings, numeric representations of meaning, and quickly finds the ones most similar to a query vector, which powers semantic search and retrieval-augmented generation.

Also known as: Vector store, vector search engine

Related terms in this glossary

How it works

Comparing a query against millions of vectors one by one is too slow, so vector databases build approximate nearest neighbor (ANN) indexes. The most common is HNSW (Hierarchical Navigable Small World graphs, Malkov and Yashunin), which trades a small amount of accuracy for large speed gains. Others include IVF and product quantization, which compress vectors to save memory.

Options fall into a few groups:

  • Dedicated engines: Pinecone, Weaviate, Qdrant, Milvus.
  • Extensions to existing databases: pgvector for PostgreSQL, vector search in Elasticsearch and OpenSearch, MongoDB Atlas Vector Search.
  • Libraries: FAISS, for teams that manage storage themselves.

Useful features beyond similarity include metadata filters (only this customer's documents), hybrid search that blends keyword and vector scores, and access controls.

Why it matters

The vector store is where a retrieval system's knowledge lives, so its filtering, freshness and access rules decide what an AI assistant can see. A common mistake is choosing a database before understanding the workload. For a few million vectors, pgvector in a PostgreSQL instance you already run is often enough and keeps data in one place. Dedicated engines earn their place at larger scale, with heavy filtering or very high query volume. Keep permissions in mind: if a user cannot open a document, retrieval should not return it either. The OWASP Top 10 for LLM Applications (2025) lists vector and embedding weaknesses as risk LLM08. See AI-powered search.

Vector Database in depth

Designing an index for production

Before choosing a product, settle the design decisions that affect any vector store:

  • Embedding model and dimension: fixed per index; changing models means re-embedding everything.
  • Distance metric: cosine, dot product or Euclidean, matching what the embedding model was trained for.
  • Metadata schema: tenant, access group, document ID, source, language and dates, so filters can run at query time.
  • Index type and parameters: HNSW settings such as graph connectivity and search breadth trade memory and speed against recall.
  • Hybrid search: whether keyword search runs in the same engine or a separate one.
  • Update pattern: how additions, edits and deletions flow in, and how quickly they must be searchable.

Example: choosing pgvector first

Example: a B2B software company wants semantic search across help articles and customer-specific documentation, with a few hundred thousand passages. Its application already runs on PostgreSQL. The team adds the pgvector extension, stores embeddings in a table with tenant ID and access columns, and builds an HNSW index. Queries filter by tenant and permissions in the same SQL statement, so customers can never retrieve each other's documents. Keyword search uses PostgreSQL full-text search, and results are merged and reranked. Backups, access control and monitoring are the ones the team already runs. The team records the query latency and recall at the current size, and agrees the thresholds at which it would evaluate a dedicated engine.

Measuring a vector store

MeasureHow
Recall of approximate searchCompare ANN results with exact brute-force search on a sample of queries
End-to-end retrieval qualityRecall at k and NDCG on labeled real queries
Query latencyHigh percentiles, with filters applied as in production
FreshnessTime from document change to searchable
Memory and storageGrowth as data grows; effect of quantization

Filtered queries deserve special testing: with restrictive filters, some ANN indexes return fewer results or slow down, depending on whether filtering happens before, during or after the vector search.

Security and data handling

Embeddings are derived from the original text and should be protected like it; research has shown that text can be partly reconstructed from some embeddings. Enforce permissions at query time with metadata filters tied to the user's identity, isolate tenants by index, namespace or filter depending on the product, and delete vectors when source documents are deleted. Personal data in indexed documents falls under the DPDP Act 2023, including deletion when the purpose ends.

Plan capacity with growth in mind. Memory needs scale with the number of vectors and their dimension, and HNSW indexes are usually held in memory for speed. Vector quantization options in many engines reduce memory at some cost to recall, which should be measured rather than assumed.

Typical problems are picking a dedicated engine before measuring the workload, missing metadata that makes filtering impossible later, no re-indexing plan for model changes, and permissions checked only in the user interface. Vector databases store embeddings, power semantic search and RAG, and feed reranking; chunking decides what each vector represents. Gepton designs retrieval stores in AI-powered search and smart recommendations.

Questions about Vector Database

Something else? Send us your question and an engineer replies with next steps.

Can one vector database serve many customers securely?

Yes, with deliberate isolation. Options include a separate index or collection per customer, namespaces or partitions within an index, or a shared index with a mandatory tenant filter on every query. Separate indexes give the strongest isolation but add management overhead at large customer counts. Whatever the approach, enforce the tenant filter in server-side code tied to the authenticated user, never from a value the client or a model supplies, and test for cross-tenant leakage.

Do we need a vector database for a small knowledge base?

Not necessarily. For a few thousand passages, embeddings can be stored in an existing database, or even searched in memory with a library such as FAISS, with acceptable speed. Extensions like pgvector add proper indexing to PostgreSQL without a new system. A dedicated vector database becomes worthwhile with large volumes, heavy filtering, high query rates or features your current database lacks. Start simple and measure.

Articles that mention Vector Database

All articles

Jump to

↑↓ to move↵ to open