pgvector vs Chroma vs Qdrant vs Milvus vs Redis Compared

Introduction

Every RAG systemClick to read tutorial: RAG Architecture Explained: Chunking, Embeddings, Retrieval and every semantic search needs somewhere to keep its embeddingsClick to read tutorial: LLM Tokens, Context Windows, Embeddings and Hallucinations and to search them quickly - a vector store. There are dozens to choose from, and five come up in almost every Java project: pgvector, Chroma, Qdrant, Milvus and Redis. All five are supported by both Spring AI and LangChain4j, so the choice is not about which framework you use, but about how you run your data. This post compares them with diagrams: what a vector store does, how approximate indexes trade accuracy for speed - measured with a Java program - why filtering is harder than it looks, each of the five stores, a comparison table, and a guide to choosing.

(Note - The products change quickly. This comparison describes them as of late 2026; check the current documentation for exact limits and versions before you decide.)

What a vector store does

A vector store keeps records of a vector together with the text it came from and metadata about it, and answers one main question: which stored vectors are most similar to this one? -
Each record holds an id, a vector, the chunk text and metadata; the store supports upserting records, deleting them, and searching for the nearest vectors with a metadata filter One record idchunk-4711 vector[0.021, -0.113, ...] text"Up to 5 unused days..." metadata (payload)source: hr/leave.pdf, dept: HR Operations upsert / deletewhen documents change search(query vector, k = 5, filter: dept = "HR")→ the 5 most similar records that match the filter, with their scores The stores differ in how they index, filter, scale and are operated - not in this basic model.
The data model and operations which all five stores share.
The five stores below all offer this model. What sets them apart is everything around it: whether it runs inside a database you already have, how it filters, how far it scales, how much memory it needs, how it is licensed, and how much operating work it creates.

Approximate search: trading recall for speed

Finding the exact nearest vectors means comparing the query with every stored vector, using the measure the index was created with (see cosine similarity vs dot productClick to read tutorial: Cosine Similarity vs Dot Product for Embeddings). That is fine for ten thousand chunks, but too slow for ten million. Vector stores therefore build an approximate nearest neighbour (ANN) index, which looks at only a small part of the data and usually, but not always, finds the true nearest vectors. Two index families dominate -
IVF splits the vectors into clusters and searches only the clusters nearest the query; HNSW links vectors into a layered graph and walks it greedily from a sparse top layer to the dense bottom layer IVF: inverted file of clusters query search only the nearest cluster(s): "nprobe" a neighbour just across a border can be missed HNSW: layered graph layer 2layer 1layer 0 long jumps on the sparse top layers, short steps on the dense bottom layer
The two common ANN index families, drawn in two dimensions.
  • IVF (inverted file) groups the vectors into clusters with k-means. A search compares the query with the cluster centres, and then only with the vectors in the nprobe nearest clusters. It builds fast and uses little memory, but recall drops when the true neighbours sit in a neighbouring cluster.
  • HNSW (Hierarchical Navigable Small World) links every vector to some of its neighbours in a graph with several layers. A search enters at the sparse top layer, walks greedily towards the query, and drops down layer by layer. It gives high recall at low latency, but the graph needs more memory and is slower to build. It is the default in most vector stores.
Both have a knob which trades speed for recall - nprobe for IVF, ef_search for HNSW. The program below builds a small IVF index over 20,000 synthetic, normalized embeddings, and measures the trade-off against exact search: recall@10 is the share of the true 10 nearest vectors which the index found.
Exact search versus an IVF index, measured
//AnnIndexDemo.java
import java.util.*;

public class AnnIndexDemo {
  static final int DIM = 32, N = 20_000, QUERIES = 100, K = 10, LISTS = 100;
  static final Random RANDOM = new Random(42);   // fixed seed, so the output is repeatable

  static float[] normalize(float[] v) {
    double norm = 0;
    for (float x : v) norm += x * x;
    norm = Math.sqrt(norm);
    for (int i = 0; i < v.length; i++) v[i] /= norm;
    return v;
  }

  static double dot(float[] a, float[] b) {
    double s = 0;
    for (int i = 0; i < a.length; i++) s += a[i] * b[i];
    return s;
  }

  // Synthetic "embeddings": points scattered around 200 topic centres, normalized like real embeddings
  static float[][] centres = new float[200][];
  static float[] randomEmbedding() {
    if (centres[0] == null)
      for (int c = 0; c < centres.length; c++) {
        centres[c] = new float[DIM];
        for (int i = 0; i < DIM; i++) centres[c][i] = (float) RANDOM.nextGaussian();
      }
    float[] centre = centres[RANDOM.nextInt(centres.length)], v = new float[DIM];
    for (int i = 0; i < DIM; i++) v[i] = centre[i] + 1.2f * (float) RANDOM.nextGaussian();
    return normalize(v);
  }

  // Exact search: compare the query with every vector
  static Set<Integer> exactTopK(float[][] data, float[] q) {
    PriorityQueue<double[]> heap = new PriorityQueue<>(Comparator.comparingDouble(e -> e[0]));
    for (int i = 0; i < data.length; i++) {
      heap.add(new double[] {dot(data[i], q), i});
      if (heap.size() > K) heap.poll();
    }
    Set<Integer> ids = new HashSet<>();
    for (double[] e : heap) ids.add((int) e[1]);
    return ids;
  }

  public static void main(String[] args) {
    float[][] data = new float[N][];
    for (int i = 0; i < N; i++) data[i] = randomEmbedding();
    float[][] queries = new float[QUERIES][];
    for (int i = 0; i < QUERIES; i++) queries[i] = randomEmbedding();

    // Build an IVF index: k-means into LISTS clusters; each vector is stored in the list of its nearest centroid
    float[][] centroids = new float[LISTS][];
    for (int c = 0; c < LISTS; c++) centroids[c] = data[RANDOM.nextInt(N)].clone();
    int[] assign = new int[N];
    for (int iteration = 0; iteration < 10; iteration++) {
      for (int i = 0; i < N; i++) assign[i] = nearest(centroids, data[i], 1)[0];
      float[][] sums = new float[LISTS][DIM];
      int[] counts = new int[LISTS];
      for (int i = 0; i < N; i++) {
        counts[assign[i]]++;
        for (int d = 0; d < DIM; d++) sums[assign[i]][d] += data[i][d];
      }
      for (int c = 0; c < LISTS; c++) if (counts[c] > 0) centroids[c] = normalize(sums[c]);
    }
    List<List<Integer>> lists = new ArrayList<>();
    for (int c = 0; c < LISTS; c++) lists.add(new ArrayList<>());
    for (int i = 0; i < N; i++) lists.get(assign[i]).add(i);

    System.out.printf("%,d vectors of %d dimensions, %d queries, top %d results each%n%n", N, DIM, QUERIES, K);
    System.out.printf("%-26s %-12s %s%n", "Search", "Recall@10", "Vectors compared per query");
    System.out.printf("%-26s %-12s %,d%n", "Exact (every vector)", "100.0%", N);
    for (int nprobe : new int[] {1, 4, 16}) {
      int found = 0;
      long compared = 0;
      for (float[] q : queries) {
        Set<Integer> truth = exactTopK(data, q);
        PriorityQueue<double[]> heap = new PriorityQueue<>(Comparator.comparingDouble(e -> e[0]));
        compared += LISTS;                                   // the query is compared with every centroid
        for (int c : nearest(centroids, q, nprobe))          // then only the vectors in the nprobe nearest lists
          for (int i : lists.get(c)) {
            compared++;
            heap.add(new double[] {dot(data[i], q), i});
            if (heap.size() > K) heap.poll();
          }
        for (double[] e : heap) if (truth.contains((int) e[1])) found++;
      }
      System.out.printf("%-26s %-12s %,d%n", "IVF, nprobe = " + nprobe,
          String.format("%.1f%%", 100.0 * found / (QUERIES * K)), compared / QUERIES);
    }
  }

  // Indexes of the `count` centroids most similar to v
  static int[] nearest(float[][] centroids, float[] v, int count) {
    Integer[] idx = new Integer[centroids.length];
    for (int i = 0; i < idx.length; i++) idx[i] = i;
    Arrays.sort(idx, (a, b) -> Double.compare(dot(centroids[b], v), dot(centroids[a], v)));
    int[] out = new int[count];
    for (int i = 0; i < count; i++) out[i] = idx[i];
    return out;
  }
}
 OUTPUT of the above code
20,000 vectors of 32 dimensions, 100 queries, top 10 results each

Search                     Recall@10    Vectors compared per query
Exact (every vector)       100.0%       20,000
IVF, nprobe = 1            53.4%        309
IVF, nprobe = 4            75.7%        910
IVF, nprobe = 16           92.9%        3,337

Explanation of the code

  • The index is built once: ten rounds of k-means put every vector into one of 100 lists, each with a centroid. In a vector store, this is the slow part of building an index, done ahead of time.
  • With nprobe = 1, a search compared about 309 vectors instead of 20,000 - roughly 65 times less work - but found only 53.4% of the true top 10. Many true neighbours were in the next cluster.
  • Searching 4 and then 16 lists raised recall to 75.7% and 92.9%, while still comparing only about 900 and 3,300 vectors. This is the dial every vector store exposes: more work per query buys higher recall.
  • The synthetic topics overlap on purpose. With clearly separated topics, recall at nprobe = 1 was over 98% in a test run - how well an index works depends on the data, which is why it is worth measuring recall on your own embeddings.

Filtering: the hard part

Real searches almost always carry a filter - only this tenant's documents, only the HR department, only documents the user may read. Combining a filter with an ANN index is harder than it looks. The diagram shows the three approaches for a search for the top 3 chunks with the filter dept = "HR", where only one chunk in five belongs to HR -
Post-filtering finds the 3 nearest chunks first and keeps only the one from HR, returning 1 result instead of 3; pre-filtering selects all HR chunks first and compares them one by one; a filter-aware index skips non-HR chunks while it searches and returns 3 HR chunks Post-filtering search first, filter after Sales HR IT top 3 nearest → keep HR → 1 result, not 3 Pre-filtering filter first, search after HR HR HR ... all HR chunks,one by one exact; slow ifthe filter is broad Filter-aware index filter while searching skip HR skip HR HR walks the index, keeps goinguntil it has 3 HR chunks 3 results The more selective the filter, the worse post-filtering gets - and the more a filter-aware index or iterative scan matters.
Three ways to combine a metadata filter with a nearest-neighbour search.
  • Post-filtering runs the ANN search for the top k, then removes the results which fail the filter. If the filter is selective, few or none of the top k survive, and the query returns fewer results than asked for.
  • Pre-filtering first selects the matching records and then searches only them. That is exact, but with a broad filter it can fall back to comparing many vectors one by one.
  • Filter-aware indexes apply the filter while walking the index, so that the search keeps going until it has k matching results.
How each store handles this is one of the most practical differences between them, as the next section shows.

The five stores

The five differ first in how they are run - inside a database you already have, inside your process, or as a separate system -
pgvector runs inside PostgreSQL next to the application's tables; Redis keeps vectors in memory in a Redis server; Chroma runs embedded or as a small server; Qdrant runs as a dedicated server or cluster; Milvus runs as a distributed set of services with separate storage Java application PostgreSQLorders, users ...+ vector columnpgvector Rediseverything in RAMcache, sessions+ vector indexRedis 8 Chromaembedded orone small serverquick start Qdrantone container,or a cluster ofequal nodesdedicated store Milvusquery nodesdata nodesobject storagecoordinatorsdistributed From left to right: fewer new systems to run, then more scale - and more to operate.
How each of the five stores is deployed next to a Java application.
pgvector is an extension for PostgreSQL which adds a vector column type, distance operators and HNSW and IVFFlat indexes. Vectors live in ordinary tables, next to the rest of the application's data, so a single SQL query can join, filter and search, inside the same transactions and backups. Since version 0.8, iterative index scans keep scanning an index until a filtered query has enough rows. Full-precision vectors can be indexed up to 2,000 dimensions; half-precision (halfvec) and binary types reduce memory. It is available in most managed PostgreSQL services, and uses the permissive PostgreSQL licence. It is the natural first choice for a Java application which already runs on PostgreSQL, up to a few tens of millions of vectors on one server.

Chroma is an open-source (Apache 2.0) embedding database built for developer convenience: it runs embedded in a Python process or as a server, and starts with one command. Its core was rewritten in Rust in 2025. Java applications reach it through its HTTP API, for example via the Spring AI and LangChain4j integrations. It is a quick way to start a prototype; for large production systems, teams more often move to one of the others.

Qdrant is an open-source (Apache 2.0) vector database written in Rust, with an official Java client using gRPC. Its HNSW index is filter-aware: with payload indexes created before the data is loaded, it adds graph links between records sharing a payload value, so filtered searches stay fast and complete. It offers scalar and binary quantization - storing each number of a vector in fewer bits - to cut memory, runs as one container or a distributed cluster, and is also sold as a managed cloud service. It is a strong default for a dedicated vector database with heavy filtering.

Milvus is an open-source (Apache 2.0) vector database built for very large scale, with storage and compute separated into services which scale on their own. It offers the widest choice of indexes - HNSW, IVF variants with product quantization, GPU indexes and DiskANN, which keeps most of the index on SSD instead of in RAM - and an official Java SDK. That power comes with more parts to operate; Zilliz Cloud offers it as a managed service, and Milvus Lite runs it embedded for development. It is the choice for hundreds of millions to billions of vectors.

Redis includes vector search in its query engine - HNSW and flat indexes over vectors stored in hashes or JSON documents, with filters on other fields - and, since Redis 8, a new vector set data type. Everything is held in memory, which gives very low latency, but makes large collections expensive. Redis 8 can be used under the AGPLv3 licence, as well as its earlier source-available licences. It fits applications which already use Redis, need the fastest responses, and have a collection that fits comfortably in memory - for example, caching LLM answers by the similarity of questions.

Side by side

pgvectorChromaQdrantMilvusRedis
What it isPostgreSQL extensionEmbedding databaseVector databaseDistributed vector databaseIn-memory store with vector search
IndexesHNSW, IVFFlatHNSWHNSW (filter-aware)HNSW, IVF, PQ, DiskANN, GPUHNSW, flat
FilteringSQL; iterative scansMetadata filtersPayload filters inside HNSWScalar filtersQuery engine filters
Typical scaleUp to tens of millionsPrototypes, small appsMillions to billionsHundreds of millions to billionsWhat fits in RAM
Java accessJDBCHTTP APIOfficial clientOfficial SDKRedis clients (Jedis, Lettuce)
LicencePostgreSQLApache 2.0Apache 2.0Apache 2.0AGPLv3 or source-available
Best whenYou already run PostgreSQLYou want to start in minutesYou need a dedicated store with heavy filteringYou have very large collectionsYou already run Redis and need speed
All five have a VectorStore implementation in Spring AI and an EmbeddingStore in LangChain4j, so application code written against those interfaces can switch stores with a configuration change - the embeddings, though, must be re-loaded into the new store.

Choosing one

Already on PostgreSQL and under tens of millions of vectors: pgvector. Already on Redis, needing the lowest latency, data fits in memory: Redis. A quick prototype: Chroma. Hundreds of millions of vectors or more: Milvus. Otherwise a dedicated store with strong filtering: Qdrant. Already on PostgreSQL, under tens of millions? Already on Redis, need the lowest latency, fits in RAM? A prototype or a small, single-team app? Hundreds of millions of vectors or more? pgvector Redis Chroma (or pgvector) Milvus Qdrant yesyesyesyesnononono: a dedicated store with strong filtering
A starting point for choosing a vector store. Ask the questions in order.
The guide is a starting point, not a rule. Three things matter more than any benchmark: the database you already operate - one less system to run, back up and secure is worth a lot; how you filter - test your real filters, including selective ones, and check that searches still return k results; and recall on your own data - measure it as in the program above, with your embeddings and your index settings, before trusting any published latency figure.

Summary

In this post we compared five vector stores for Java applications. We saw that all of them store vectors with text and metadata and answer nearest-neighbour searches, and that they rely on approximate indexes - IVF and HNSW - which trade recall for speed, a trade-off we measured in Java: from 53% to 93% recall while still comparing only a fraction of the vectors. We looked at why filtering is hard for ANN indexes, and then at each store: pgvector inside PostgreSQL, Chroma for a quick start, Qdrant with filter-aware HNSW, Milvus for very large collections, and Redis for in-memory speed. Lastly, we put them side by side and went through a guide to choosing. How the vector store fits into the whole pipeline is explained in RAG architecture explainedClick to read tutorial: RAG Architecture Explained: Chunking, Embeddings, Retrieval.