Skip to content

What is Vector Database?

Generative AI & LLMs, explained by the engineers who build it. Definition, how it works, use cases and common questions.

Vector Database definition

A vector database is a database designed to store embeddings, which are numeric vectors representing the meaning of text, images or other data, and to quickly find the vectors most similar to a query. It powers semantic search, recommendations and retrieval-augmented generation by matching items on meaning rather than on exact keywords.

How does a vector database work?

Each item, such as a paragraph from a manual or a product photo, is passed through an embedding model that outputs a vector of hundreds or thousands of numbers. The database stores that vector with an ID and metadata such as source, date and access rights. At query time, the question is embedded with the same model, and the database returns the stored vectors closest to it by cosine similarity, dot product or Euclidean distance.

Comparing a query with every stored vector is too slow at scale, so vector databases use approximate nearest neighbor (ANN) indexes. HNSW builds a layered graph that can be searched in a few hops. IVF partitions vectors into clusters and searches only the nearest ones, and product quantization compresses vectors to save memory. Each index trades a little recall for large gains in speed.

The line between these categories keeps blurring, as general databases add vector indexes and dedicated engines add keyword search, filtering and transactions. For most teams the deciding factor is operational: whether running another stateful system is worth it, or whether the database they already back up, monitor and secure can handle vectors too.

  • Dedicated vector databases: Pinecone, Weaviate, Qdrant, Milvus and Chroma.
  • Extensions to existing databases: pgvector for PostgreSQL, MongoDB Atlas Vector Search, Redis.
  • Search engines with vector support: Elasticsearch and OpenSearch.
  • Libraries for building custom indexes: FAISS and hnswlib.

Vector database vs traditional database

A relational database answers exact questions: rows where status equals "open" and amount exceeds 500. A vector database answers fuzzy ones: the ten passages most similar in meaning to "how do I cancel my plan", even when they say "terminate subscription" instead. Most applications need both, which is why filtering by metadata during vector search, and hybrid search that combines vectors with keyword matching, are essential features.

Use cases and an example

Worked example: an ecommerce site embeds every product title, description and image. When a shopper searches "something warm for hiking in the rain", the vector search returns waterproof insulated jackets even though none contains those exact words, while a metadata filter keeps out-of-stock items away from the results.

  • Retrieval for RAG chatbots and internal knowledge assistants.
  • Semantic and multilingual search.
  • Product and content recommendations.
  • Duplicate and near-duplicate detection.
  • Image similarity search and anomaly detection.
  • Matching job candidates to roles, or support tickets to known issues.

How to choose a vector database

Consider data volume, query rate, metadata filtering, hybrid search support, multi-tenant isolation, update frequency, hosting model and cost. For many applications with up to a few million vectors, pgvector inside an existing PostgreSQL database is enough and avoids running another system. Nexzem usually starts there and moves to a dedicated engine only when load tests show a real need. Benchmark candidates with your own embeddings and filters, since published numbers rarely match real query patterns.

Vector Database: common questions

Something else on your mind? Ask a consultant and get a reply within one business day.

Do I need a vector database for RAG?

You need vector search, but it does not have to be a separate product. PostgreSQL with pgvector, Elasticsearch or OpenSearch work well for many RAG systems. A dedicated vector database becomes attractive with very large collections, high query volumes or advanced needs like heavy filtering at scale.

What is the difference between vector search and keyword search?

Keyword search, such as BM25, matches exact terms and excels at names, codes and rare words. Vector search matches meaning, so it finds paraphrases and related concepts. They fail in different ways, which is why hybrid search that merges both result lists usually gives the best retrieval quality.

Is pgvector good enough for production?

For many workloads, yes. It supports HNSW and IVF indexes, combines vector search with normal SQL filters and joins, and inherits PostgreSQL's backups, replication and access control. At very high scale or with demanding latency targets, a dedicated vector engine may perform better, so load testing with realistic data is worthwhile.

Keep exploring the generative ai & llms glossary

Need Vector Database in your product?

A solutions consultant replies within one business day with next steps, a rough estimate and a suggested team.