Vector Databases: pgvector, Pinecone, Qdrant, Chroma

RAG, AI Agents & MCP · Retrieval-Augmented Generation (RAG) · 7 min read · Updated

A vector database stores vectors and finds the nearest ones quickly, using an index instead of comparing against everything.

What to look for

  • Search speed and accuracy at your data size.
  • Metadata filtering (for example only this user's documents, or only English).
  • Updates and deletes without rebuilding everything.
  • Security and access control, especially for private data.
  • Cost and how much you must operate yourself.

Common options

  • PostgreSQL with pgvector: adds vector search to a database you may already run. Good when you want one system.
  • MongoDB vector search: available on MongoDB Atlas, handy if your data is already in Mongo. Check support if you use another Mongo-compatible server.
  • Pinecone: a managed service, little to operate.
  • Qdrant and Weaviate: open-source engines that you can self-host or use as a service.
  • Chroma: simple and popular for prototypes and local work.

Distance metrics

Cosine similarity, dot product and Euclidean distance are the common choices. Use the one your embedding model recommends.

Security and privacy

  • Filter by user or tenant on every query, so people only retrieve their own documents.
  • Encrypt data and restrict access to the database.
  • Support deletion: if a user deletes a document, delete its vectors too.

Start simple

For a small project, store vectors beside your existing records and compute similarity in code, or use the vector features of the database you already have. Move to a dedicated engine when scale or speed demands it.

Frequently asked questions

Do I need a separate vector database?

Not always. If your current database supports vector search and your data is modest, start there. Add a dedicated one when you need more scale or features.

How do I keep one user's data from appearing for another?

Store a user or tenant id with every chunk and filter on it in every query. Test it with accounts that should not see each other's data.