Learn/Generative AI, RAG & Agents/MODULE 2: RETRIEVAL AUGMENTED GENERATION (RAG)
Lesson 15 of 37 · 2 min read

2.4 Vector Databases

When you have thousands or millions of document embeddings, you can't just loop through all of them every time someone asks a question — that would be too slow.

You need a specialized system designed to find similar vectors quickly.

This is what a vector database does.

What Is a Vector Database?

A vector database is a kind of database optimized for storing embeddings and finding the closest matches to a query embedding.

Popular ones include:

  • Pinecone (cloud-hosted, fully managed)
  • Weaviate (open-source with cloud options)
  • Chroma (lightweight, often used for prototypes)
  • Qdrant (open-source, focus on performance)
  • Milvus (open-source, scales to huge datasets)
  • pgvector (an extension to PostgreSQL, lets you add vector search to a regular database)

Major cloud providers (AWS, Google Cloud, Azure) also offer their own vector database services.

What Makes Vector Databases Special

The core challenge a vector database solves is called Approximate Nearest Neighbor (ANN) search: finding the vectors closest to a query vector, fast, even when there are millions of them.

Doing this exactly (comparing the query against every single stored vector) is too slow at scale.

So vector databases use clever indexing techniques — algorithms with names like HNSW (Hierarchical Navigable Small Worlds) or IVF (Inverted File Index) — that find almost the closest matches very quickly.

For most RAG applications, "almost" is more than good enough.

What Else Vector Databases Store

In addition to the embedding vectors themselves, vector databases store:

  • The original text (so you can pass it to the LLM)
  • Metadata like document title, source URL, date, author, tags
  • Sometimes a unique ID for each chunk

This metadata is important.

You can use it to filter searches — for example, "find similar vectors, but only among documents tagged 'HR policy' from the last twelve months."

Keep going with a free account

A free account saves your progress across lessons and lets you pick up where you left off.