Best vector databases for RAG in 2027: pgvector, Qdrant and more

Ten vector databases for RAG as of 11 November 2026: pgvector, Qdrant, Pinecone, Weaviate, Chroma, Milvus and more, with licences, index types and limits.

Vector databases for RAG, compared: cover for Best vector databases for RAG in 2027: pgvector, Qdrant and more

A vector database stores embeddings, the lists of numbers that represent the meaning of text, and returns the stored items nearest to a query vector, which is how a retrieval-augmented generation (RAG) system finds the passages to hand a language model. The ten options below run from the pgvector extension for PostgreSQL to the FAISS library, and Anthropic says a knowledge base under 200,000 tokens may need no retrieval at all.

Last updated: 11 November 2026.

What does a vector database do in a RAG system?

A vector database finds the stored vectors closest to a query vector, so a RAG system can retrieve passages by meaning instead of by keyword. OpenAI's embeddings guide defines an embedding as a list of floating point numbers whose distance from another list measures relatedness. Ollama's documentation says embedding vectors typically have 384 to 1024 dimensions and that its endpoint returns unit-length vectors, for which cosine similarity is the dot product. The original RAG paper by Lewis and others used a dense vector index of Wikipedia reached through a neural retriever.

Exact search compares the query with every stored vector. Approximate search builds an index such as HNSW, a multi-layer graph that Malkov and Yashunin's 2016 paper says gives logarithmic complexity scaling, and trades some recall for speed. The script below does the exact version on four hypothetical help-desk snippets with invented 4-dimensional vectors.

import numpy as np

# Hypothetical 4-dimensional "embeddings" for four help-desk snippets
names = ["refund policy", "leave policy", "invoice due dates", "office wifi"]
M = np.array([
    [0.9, 0.1, 0.0, 0.2],
    [0.1, 0.9, 0.1, 0.0],
    [0.8, 0.0, 0.3, 0.1],
    [0.0, 0.1, 0.9, 0.3],
])
query = np.array([0.88, 0.08, 0.05, 0.18])  # hypothetical embedding of a refund question

sims = (M @ query) / (np.linalg.norm(M, axis=1) * np.linalg.norm(query))
for i in np.argsort(-sims)[:3]:
    print(f"{sims[i]:.3f}  {names[i]}")

Run with Python 3.12 and numpy 2.5.4, it prints the top three by cosine similarity. A FAISS exact index (faiss-cpu 1.16.0, inner product on normalised vectors) printed the same three rows.

0.998  refund policy
0.949  invoice due dates
0.201  leave policy

Real embeddings have hundreds of dimensions, and that is where memory matters. The FAISS wiki gives 4 times d bytes per vector for a flat index, so a hypothetical 1,000,000 vectors of 768 dimensions need 3072 bytes each, 3.072 GB in total or 2.86 GiB, before any index overhead. Quantised and graph indexes exist to cut that cost or the search time.

Do you need a vector database for RAG?

A RAG system does not always need a vector database. Anthropic's post of 19 September 2024 says a knowledge base smaller than 200,000 tokens, about 500 pages, can simply be put into the prompt. Beyond that, the question is operational: how often the data changes, whether queries filter on metadata, and whether other services share the store. For a small corpus held in memory, the script above is already a complete retrieval layer.

A database earns its place when documents are added and deleted continuously, when each query must respect filters such as department or date, or when the data must outlive the process. For the primer, see what RAG is in AI. Vector stores sit beside other database types, covered in types of databases.

Which vector databases fit a stack that already runs a database or search engine?

pgvector, MongoDB Vector Search, Elasticsearch or OpenSearch, and Redis add vector search to software a team may already operate, which avoids running a new system.

pgvector

pgvector is an open-source PostgreSQL extension for vector similarity search, under the PostgreSQL licence (v0.8.7, 1 October 2026). It searches exactly by default and offers HNSW and IVFFlat indexes, and keeps JOINs and point-in-time recovery. A hypothetical team with policy documents already in PostgreSQL can add an embedding column and order rows by embedding <=> query_vector. The limit is filtering: with an approximate index the filter runs after the index scan, so the README says a condition that matches 10% of rows with the default hnsw.ef_search of 40 returns only 4 rows on average.

MongoDB Vector Search is MongoDB's vector search feature, named so in current documentation, where the older Atlas Vector Search address redirects to it. It supports approximate search with HNSW and exact search through the $vectorSearch aggregation stage, which must come first in a pipeline. A hypothetical product team with documents already in MongoDB can search embeddings stored beside them. The limit is coupling: the documentation covers Atlas, self-managed and local Atlas deployments, so a team on another database adds a second store. The document model is compared in MongoDB vs MySQL.

Elasticsearch and OpenSearch

Elasticsearch, from Elastic, and OpenSearch are search engines that keep embeddings in a dense_vector or knn_vector field beside text. Elastic offers approximate kNN for large workloads and exact kNN for small or pre-filtered sets, and requires query and document vectors to come from the same model; OpenSearch lists the methods hnsw, ivf, flat and disk_ann. A hypothetical help centre already running keyword search can add a vector field to the same index. The limit is licensing: Elasticsearch defaults to a triple licence (AGPLv3, SSPL v1 and Elastic License 2.0), while OpenSearch is Apache 2.0.

Redis

Redis's documentation says Redis includes a vector database with filtering on text, numeric, geospatial and tag metadata, using FLAT, HNSW or SVS-VAMANA indexes (the last added in Redis 8.2) over vectors stored in hashes or JSON. A hypothetical team already using Redis for session data can reuse it for retrieval. The limit is licensing and scale: from Redis 8 the open-source download is offered under RSALv2, SSPLv1 or AGPLv3, Redis says RSALv2 is not an open source licence, and FLAT is advised for datasets under 1M vectors.

Which dedicated vector databases and libraries are there?

Pinecone, Qdrant, Weaviate, Chroma and Milvus are dedicated vector databases and FAISS is a similarity search library, ranging from a managed service to in-memory search.

Pinecone

Pinecone Database is a managed service that Pinecone's documentation now describes as a search engine for AI agents and applications. One index serves full-text, semantic, sparse-vector and hybrid search through a Documents API. A hypothetical start-up that does not want to run servers can use it hosted, or deploy the data plane in its own AWS, GCP or Azure account through Bring Your Own Cloud. The limit is migration: an index stays on the API it was created with, so a legacy index never moves to the Documents API on its own.

Qdrant

Qdrant is a vector similarity search engine and vector database written in Rust, under the Apache 2.0 licence, that stores points: vectors with an additional payload. Its README stresses filtering, and its documentation says it currently uses only HNSW for dense vectors, with separate payload indexes for filters. A hypothetical marketplace can rank listings by similarity while filtering on category. The limit is a default: the README warns that its quick-start Docker command starts an insecure deployment without authentication, open to all network interfaces.

Weaviate

Weaviate is a cloud-native vector database that stores objects and vectors together and combines similarity search with keyword filtering, RAG and reranking in one query interface. It offers HNSW, Flat, Dynamic and HFresh indexes, and its guide suggests Flat for small per-tenant datasets and Dynamic for collections that start small and grow. A hypothetical SaaS product with one small dataset per customer fits that pattern. The limit is licensing detail: most code is BSD-3-Clause, but code in the wl directory needs a separate enterprise licence key.

Chroma

Chroma is open-source data infrastructure for AI under the Apache 2.0 licence, installed with pip install chromadb and run in memory, as a server, or as hosted Chroma Cloud. A hypothetical student project can add documents with metadata and query by text in a few lines. The limit is a default: Chroma's configuration page says the distance space defaults to l2 (squared L2), with cosine and ip as alternatives, so a project comparing text embeddings by cosine should set the space when creating the collection.

Milvus

Milvus is an open-source vector database written in Go and C++, under the Apache 2.0 licence within the LF AI & Data Foundation. It lists HNSW, IVF, FLAT, SCANN and DiskANN index types and runs as Standalone on one machine, as Milvus Lite installed with pip, or as a distributed Kubernetes-native cluster, with Zilliz Cloud as the managed service. A hypothetical team expecting large collections can prototype on Lite and move up. The limit is weight: a distributed design built for scale is more to run than an extension or library for a small corpus.

FAISS

FAISS is a library from Meta's Fundamental AI Research group for similarity search and clustering of dense vectors, MIT licensed, written in C++ with Python wrappers and GPU implementations. Its indexes include exact flat, HNSW, IVF and quantised types. A hypothetical research notebook can hold embeddings in memory and search them exactly, as in the script above. The limit is scope: FAISS is a library, not a database server, and flat indexes do not store vector ids unless wrapped in an IndexIDMap, so ids and metadata are the application's job.

How do the ten compare?

The ten vector databases differ mainly in hosting, licence and index types. The table sets licence or hosting as each repository or documentation page states it on 11 November 2026, beside the index types those pages name.

ToolBest forMain limitLicence or hosting as statedIndex types named
pgvectorTeams already on PostgreSQLFilter runs after an approximate index scanPostgreSQL licence; runs inside PostgresHNSW, IVFFlat; exact by default
MongoDB Vector SearchDocuments already in MongoDBTied to MongoDB deploymentsAtlas, self-managed or local AtlasHNSW (approximate), exact
Elasticsearch and OpenSearchTeams that already run searchLicence terms differElasticsearch: AGPLv3, SSPL v1 or Elastic License 2.0; OpenSearch: Apache 2.0hnsw, int8_hnsw, int4_hnsw, bbq_hnsw, flat; hnsw, ivf, flat, disk_ann
RedisTeams already running RedisLicence options; FLAT for under 1M vectorsRSALv2, SSPLv1 or AGPLv3 from Redis 8FLAT, HNSW, SVS-VAMANA
PineconeNo servers to runLegacy indexes need migrating to the Documents APIManaged service; Bring Your Own Cloud optionNot named on the overview page
QdrantFiltered similarity searchQuick-start Docker is insecure by defaultApache 2.0; Qdrant CloudHNSW
WeaviateObjects plus vectors in one storeEnterprise features licensed separatelyBSD-3-Clause for most codeHNSW, Flat, Dynamic, HFresh
ChromaPrototypes and small appsDefault distance is l2, not cosineApache 2.0; local, server or Chroma CloudHNSW (single node)
MilvusLarge, distributed collectionsMore to run than a libraryApache 2.0; Standalone, Lite, cluster, Zilliz CloudHNSW, IVF, FLAT, SCANN, DiskANN
FAISSIn-memory research and custom stacksLibrary: ids and metadata are your jobMIT; libraryFlat, HNSW, IVF, PQ and SQ variants

Which vector database should you choose?

The criterion here is what a team already runs and what each project's documentation says about filtering, licence and hosting. No benchmark is used, because vendor figures rest on different methods.

  • Already running PostgreSQL: start with pgvector, since it keeps vectors beside the rows they describe and searches exactly until an index is added.
  • Documents in MongoDB, or search in Elasticsearch or OpenSearch: try that product's own vector search first.
  • No wish to operate servers: Pinecone, Qdrant Cloud, Chroma Cloud or Zilliz Cloud for Milvus.
  • Queries that filter heavily on metadata: Qdrant, whose README stresses filtering, tested against pgvector's filter-after-index behaviour.
  • A notebook, a prototype or a small corpus: Chroma, FAISS or the numpy script above.
  • Very large collections across machines: Milvus.

What keeps the choice honest?

A vector database choice stays honest when it is tested with the team's own questions and documents. Query vectors must come from the same embedding model as the stored vectors, as Elastic's documentation notes, so changing the embedding model means re-embedding everything.

pgvector's README warns that results change after an approximate index is added, so compare the indexed answers with the exact ones. Licences and free tiers change: Elastic announced AGPL as an added option on 29 August 2024, and Redis's current terms apply from Redis 8. Retrieval can also be exposed to agents through the Model Context Protocol, explained in what MCP is, and a local model can supply the embeddings, as in running LLMs locally with Ollama, LM Studio and llama.cpp.

Where do vector databases fit in an AI and ML programme?

Certification in Artificial Intelligence and Machine Learning is an online programme from Vishlesan i-Hub, IIT Patna, delivered on Masai's online platform, that covers Python, machine learning, deep learning, generative AI and LLMs, agentic systems and deploying models to production. Its curriculum names text embeddings, Retrieval-Augmented Generation and REST APIs for models, the pieces a retrieval layer connects.

Frequently asked questions

What is a vector database?

A vector database is a system that stores embeddings, lists of numbers representing the meaning of text or images, and finds the stored vectors nearest to a query vector. It can search exactly or through an approximate index such as HNSW. Retrieval-augmented generation uses it to fetch relevant passages for a language model.

Do you need a vector database for RAG?

A RAG system does not always need a vector database. Anthropic's post of 19 September 2024 says a knowledge base smaller than 200,000 tokens, about 500 pages, can be put straight into the prompt. A vector database becomes useful when the data is large, changes often, needs metadata filters or must be shared between services. A small in-memory index is enough for many prototypes.

What is the difference between pgvector and Pinecone?

pgvector is an open-source extension that adds vector search to PostgreSQL, so vectors live beside relational data and it runs wherever Postgres runs. Pinecone Database is a managed service reached through its Documents API, with a Bring Your Own Cloud option. The choice is mostly operational: extend a database already run, or buy a hosted service.

What is the difference between HNSW and IVFFlat?

Both are approximate index types in pgvector. The pgvector README says HNSW builds a multilayer graph with better speed-recall performance but slower builds and more memory, while IVFFlat divides vectors into lists, builds faster and uses less memory but has lower query performance. HNSW can be created on an empty table, whereas IVFFlat should be built after data exists.

Is FAISS a vector database?

FAISS is a library for similarity search and clustering of dense vectors, developed at Meta's Fundamental AI Research group, not a database server. It offers flat, HNSW, IVF and quantised indexes, but its flat indexes do not store vector ids on their own. Applications handle storage of ids, metadata and updates themselves, or use a database built around it.

What distance does Chroma use by default?

Chroma's configuration documentation says the default distance space is l2, the squared L2 norm, with cosine and ip (inner product) as the other options. A project that compares text embeddings by cosine similarity should therefore set the space to cosine when creating the collection instead of relying on the default.

Next step

The retrieval choices above, from embeddings to indexes to the API in front, are the practical end of RAG. The Certification in Artificial Intelligence and Machine Learning curriculum covers the surrounding topics, from text embeddings to deploying models behind a REST API.

×

Our Courses

Practice-Based Learning Tracks, Supercharged By A.I.