Calculate total infrastructure cost to store and search 10 million vector embeddings: pgvector on dedicated Hetzner NVMe ($46/mo) vs Pinecone Serverless vs Qdrant Cloud.
-- Enable pgvector extension
CREATE EXTENSION IF NOT EXISTS vector;
-- Documents table for 1536-dimensional embeddings
CREATE TABLE doc_embeddings (
id BIGSERIAL PRIMARY KEY,
document_id VARCHAR(64) NOT NULL,
chunk_index INT NOT NULL,
embedding vector(1536) NOT NULL
);
-- Production HNSW index (m=16, ef_construction=64) for <10ms query latency
CREATE INDEX ON doc_embeddings USING hnsw (embedding vector_cosine_ops)
WITH (m = 16, ef_construction = 64);
Storing 10 million vector embeddings of 1536 dimensions (the standard output size of OpenAI `text-embedding-3-small` or `text-embedding-ada-002`) represents a serious inflection point in vector database economics. In uncompressed 32-bit floating point format (FP32), 10M vectors consume 61.44 GB of raw RAM just for vector storage, excluding HNSW graph edges and metadata payloads.
Running this in standard cloud RAM costs over $250/month. However, by combining Scalar Quantization (int8) or Product Quantization (PQ) with disk-backed indexing, storage requirements drop to under 16 GB, making it possible to host 10 million vectors on a single $45/month server.
| Database Engine | Hosting Strategy | RAM Footprint | Monthly Infrastructure Cost | p95 Query Latency |
|---|---|---|---|---|
| Qdrant (Quantized) | Hetzner AX52 (64GB RAM, NVMe) | 16 GB (int8 + on-disk payload) | $59.00 / month | 8 ms |
| Milvus (Knowhere) | AWS EKS (2x r6i.xlarge) | 32 GB (HNSW + SQ8) | $368.00 / month | 12 ms |
| Pinecone Serverless | Fully Managed (AWS us-east-1) | Managed Ephemeral | $184.00 / month | 38 ms (Cold) / 14 ms (Warm) |
| PostgreSQL + pgvector | AWS RDS (db.m6g.2xlarge, HNSW) | 64 GB (Full RAM index) | $480.00 / month | 22 ms |
While `pgvector` on Postgres is exceptional for prototypes under 1 million vectors, scaling to 10M vectors with HNSW indexes triggers major operational challenges: HNSW index builds on 10M rows require over 3 hours of 100% CPU utilization, vacuum operations lock write buffers, and index memory can easily starve Postgres shared buffers, degrading normal transactional query throughput.
For datasets scaling past 10 million vectors, Qdrant's distributed clustering architecture shards collections across multiple nodes. By placing vector payload storage on fast NVMe drives while keeping quantized vectors in RAM, a 3-node bare-metal cluster delivers high-availability search across 30 million vectors for under $180/month total infrastructure spend, compared to $950+/month on legacy pod-based vector managed clouds.
-- Optimize maintenance memory before building HNSW index on 10M rows
SET maintenance_work_mem = '16GB';
SET max_parallel_maintenance_workers = 8;
-- Build HNSW index with cosine distance and halfvec (FP16) storage
CREATE INDEX ON document_embeddings
USING hnsw ((embedding::halfvec(1536)) halfvec_cosine_ops)
WITH (m = 16, ef_construction = 128);
Binary Quantization Rescoring Pipeline: Implement a two-pass search pipeline: perform initial Top-100 candidate retrieval using binary quantized vectors (Hamming distance) in under 2ms, followed by exact FP16 cosine distance rescoring on the top 20 candidates for maximum retrieval precision.