Vector Databases Explained: pgvector, Pinecone, Weaviate, Qdrant

What vector databases do, how HNSW and IVF indexes work, how pgvector, Pinecone, Weaviate and Qdrant compare, and when you do not need one at all.

DIDatainter TeamOCT 26, 20258 MIN READTECHNOLOGY

Vector databases went from a niche tool to a default line item in AI architecture diagrams in about two years. The pitch is appealing: store embeddings, query by similarity, and your application understands meaning instead of keywords. But a lot of teams adopt a dedicated vector database before they have measured whether they need one, and then discover they are operating another stateful system with its own backups, scaling limits and cost.

This article explains what a vector database actually does, how the main index types trade accuracy against speed and memory, how four popular options compare, and a candid look at when a simpler approach is better.

What a vector database does

An embedding model turns a piece of text, an image or a product into a list of numbers, typically 384 to 3,072 of them. Items with similar meaning end up close together in that space. A vector database stores these vectors alongside identifiers and metadata, and answers one core query: given a query vector, return the k nearest neighbors.

Doing that exactly means comparing the query against every stored vector, which costs O(n) per query. For 10,000 vectors that is trivial. For 50 million vectors of 1,024 dimensions it means scanning about 200 GB of data per query. So production systems use approximate nearest neighbor (ANN) indexes, which return results that are very close to exact, at a fraction of the time and memory traffic.

Around that core, a useful database adds:

  • Metadata filtering, such as tenant, language, date or permission, combined with similarity.
  • Hybrid search, mixing vector similarity with keyword scoring.
  • Updates and deletes without rebuilding everything.
  • Persistence, replication and backup.
  • Quantization to shrink vectors and speed up distance computation.

Distance metrics matter too. Cosine similarity, inner product and Euclidean distance are the common options. Use the metric your embedding model was trained with; for normalized vectors, cosine and inner product give the same ranking.

Index types: HNSW, IVF and friends

Flat (exact)

A flat index does a brute-force scan. It gives perfect recall, needs no build time and has no tuning. With modern CPUs and SIMD, scanning a few hundred thousand vectors takes tens of milliseconds, which is often acceptable. It is the right baseline and the right answer for small collections.

HNSW

Hierarchical Navigable Small World graphs are the most widely used ANN index. Vectors are nodes in a multi-layer graph. Search starts at a sparse top layer, greedily moves toward the query, and descends to denser layers. Typical parameters:

  • M: the number of links per node, commonly 16 to 64. Higher values improve recall and increase memory.
  • ef_construction: the breadth of search during build, often 100 to 400. Higher means a better graph and slower inserts.
  • ef_search: the breadth at query time. This is your runtime recall-versus-latency dial.

HNSW offers excellent recall (often above 95 to 99 percent) with single-digit millisecond latency, and it supports incremental inserts. The cost is memory: the graph lives in RAM for best performance, adding roughly 100 to 300 bytes per vector on top of the vectors. Deletes are awkward since graphs are repaired lazily, so heavy-churn workloads need periodic rebuilds.

IVF

An inverted file index clusters vectors using k-means into nlist partitions. At query time it finds the nprobe closest centroids and searches only those partitions. IVF builds faster than HNSW, uses less memory overhead and works well on disk, but recall depends on nprobe and on how well the clusters match your data. It also needs a training step, and quality drifts if the data distribution changes after training. Typical settings are nlist around the square root of n, and nprobe of 1 to 10 percent of nlist.

Quantization and disk-based indexes

Product quantization (PQ) and scalar quantization compress vectors, for example from 4 bytes per dimension to 1 byte or less. Memory drops by 4x to 32x, at a recall cost that you can often recover by reranking the top candidates with full-precision vectors. Disk-oriented graph indexes such as DiskANN-style designs keep a compressed copy in memory and full vectors on SSD, which makes hundreds of millions of vectors feasible on modest hardware.

Index Recall Query speed Memory Updates Best for
Flat Exact Slow at scale Vectors only Trivial Under ~100k vectors
HNSW High Very fast High Good, deletes lazy Low-latency search, up to hundreds of millions with quantization
IVF Medium to high Fast Low to medium Needs retraining over time Large static datasets, memory-constrained
IVF with PQ Medium Fast Very low Needs retraining Billion-scale, cost-sensitive

Pick the index from your recall target, memory budget and update pattern, not from the vendor name on the box.

Technology · Vector Databases Explained: pgvector, Pinecone, Weaviate, Qdrant

The four contenders

pgvector

pgvector is a PostgreSQL extension that adds a vector type, distance operators and both HNSW and IVFFlat indexes. Its great strength is that vectors live next to your relational data. You can join, filter with SQL, use transactions, back up with your existing tooling and apply row-level security. Hybrid search is straightforward by combining with PostgreSQL full-text search.

CREATE EXTENSION vector;
CREATE TABLE chunks (
  id bigserial PRIMARY KEY,
  tenant_id int NOT NULL,
  body text,
  embedding vector(1024)
);
CREATE INDEX ON chunks USING hnsw (embedding vector_cosine_ops)
  WITH (m = 16, ef_construction = 128);

SET hnsw.ef_search = 80;
SELECT id, body
FROM chunks
WHERE tenant_id = 42
ORDER BY embedding <=> $1
LIMIT 10;

Limits: a single node bounds you. Index builds on tens of millions of vectors take a long time and a lot of memory, and filtered queries with restrictive filters can return fewer results than requested when the index scans a limited candidate set (newer versions add iterative scans to mitigate this). Experience suggests pgvector is comfortable up to a few million vectors and workable into the tens of millions with good hardware and tuning.

Pinecone

Pinecone is a fully managed, proprietary service, with a serverless offering that separates storage from compute and bills by usage. You do not run infrastructure, and it scales to large collections with namespaces for multi-tenancy. Trade-offs: it is closed source and cloud only, your data leaves your database, costs can climb with high query volume, and you rely on a vendor for filter capabilities and index behavior. It is a strong fit for teams without operations capacity who want the shortest path to a scaled search service.

Weaviate

Weaviate is open source, written in Go, and can be self-hosted or used as a managed cloud. It stores objects with properties and vectors, has built-in hybrid search combining BM25 and vector scores, and offers modules for vectorizing data at ingestion. Multi-tenancy is a first-class feature, with per-tenant shards that can be offloaded when inactive. It uses HNSW with optional compression. It suits teams who want a feature-rich search engine with a schema and hybrid queries in one system, and who accept running a cluster.

Qdrant

Qdrant is open source, written in Rust, and available self-hosted or as a managed cloud. It is known for strong filtering performance, since payload filters are integrated into HNSW traversal rather than applied after the fact. It supports scalar, product and binary quantization, on-disk vectors, sparse vectors for hybrid retrieval, and sharding and replication for scale. It fits workloads with heavy metadata filtering and a need to control memory cost.

A comparison

Dimension pgvector Pinecone Weaviate Qdrant
Deployment Inside PostgreSQL Managed only Self-host or cloud Self-host or cloud
License Open source Proprietary Open source Open source
Index types HNSW, IVFFlat Proprietary HNSW, flat HNSW
Hybrid search Via Postgres full-text Sparse-dense Built-in BM25 Sparse vectors
Filtering Full SQL Metadata filters Property filters Strong payload filters
Practical scale Millions, tens with tuning Very large Large Large
Operational burden Low if you run Postgres Lowest Medium Medium
Transactions with app data Yes No No No

Whichever you choose, treat the choice as reversible. Keep embeddings reproducible from source text, store the embedding model name with each vector and isolate access behind a small repository interface.

When you do not need a vector database

Many projects reach for a dedicated store too early. Consider these cases first.

  • Small corpora. If you have under 50,000 chunks, a flat scan in memory, using NumPy, SQLite with an extension or pgvector without an index, is simple, exact and fast. One million 768-dimensional float32 vectors take about 3 GB and a brute-force query on a modern server can complete in well under 100 milliseconds.
  • Keyword search would do. If users search for product codes, names or exact phrases, BM25 in PostgreSQL, Elasticsearch or OpenSearch already solves the problem. Many “semantic search” projects improve most from better lexical search, filters and synonyms.
  • You already run PostgreSQL. Adding pgvector avoids a new system, keeps vectors transactionally consistent with the rows they describe, and removes a class of synchronization bugs where the vector store and the main database disagree.
  • Structured questions. Queries like “invoices over 10,000 dollars last quarter” are SQL problems. Embeddings add nothing.
  • Cached or precomputed results. If recommendations can be computed offline and served as a lookup table, you may need no online ANN at all.

Dedicated systems earn their place when you have tens of millions of vectors or more, strict latency at high query volume, heavy filtered search with large tenant counts, or a team that wants to avoid managing a database and will pay for it.

How to choose

  1. Estimate the vector count in one and three years, and the dimension. Multiply to get raw memory.
  2. Define the recall target and latency budget, for example recall at 10 above 95 percent at p95 under 100 milliseconds.
  3. List the filters you need and how selective they are. Test them, since filtered ANN is where systems differ most.
  4. Measure on your own data. Build a benchmark with real embeddings and queries, compute recall against exact search, and test with realistic write load.
  5. Count the total cost including engineering time, not just the instance price.

A sensible default for many products: start with pgvector on your existing PostgreSQL, instrument recall and latency, and move to a dedicated engine when the numbers say so. At Datainter, migrations between stores have been routine for exactly this reason, because the interface is narrow when it is designed that way from the start.

Key takeaways

  • A vector database stores embeddings and answers approximate nearest-neighbor queries, usually combined with metadata filters.
  • HNSW gives high recall and low latency at the price of memory; IVF and quantization save memory and cost recall, and often need reranking.
  • pgvector wins on simplicity and transactional consistency up to millions of vectors; Pinecone minimizes operations; Weaviate offers integrated hybrid search; Qdrant is strong on filtering and memory control.
  • Test filtered queries and updates on your own data, because the largest differences between systems show up there.
  • Small corpora, keyword-friendly queries and structured questions often need no vector database at all.
  • Keep embeddings reproducible and hide the store behind a narrow interface so you can change it later.
#vector database#pgvector#hnsw#search
DI
Datainter TeamEngineers, designers and operators building software and fintech products from Medellín, Tigard and Luxembourg.

Building something in this space?

Talk to the team that ships and operates it. We reply within one business day.

Start a project
Chat with us on WhatsAppUSUALLY REPLIES WITHIN MINUTES