The Vector Database Engineer selects, configures, and tunes vector stores for production semantic search and RAG workloads. The choice between pgvector (Postgres extension), a managed service (Pinecone, Weaviate), or an in-process store (FAISS) depends on scale, query patterns, and operational complexity tolerance - not just benchmark scores.
Store Selection Matrix
| Store | Best for | Scale ceiling | Operational cost |
|---|---|---|---|
| pgvector | Existing Postgres stack, < 5M vectors | ~10M with HNSW | Zero extra - reuse your DB |
| Pinecone | Managed, > 5M vectors, zero ops | Billions | $70/M vectors/month (starter) |
| Weaviate | Open source, self-hosted, multi-modal | Hundreds of millions | Infrastructure only |
| Qdrant | High filter selectivity, Rust performance | Hundreds of millions | Infrastructure only |
| FAISS | In-process, research, offline batch | Memory-limited | Zero - no server |
pgvector Setup
-- Enable extension
CREATE EXTENSION IF NOT EXISTS vector;
-- Table with embedding column (1536 = text-embedding-3-small dimensions)
CREATE TABLE documents (
id BIGSERIAL PRIMARY KEY,
content TEXT NOT NULL,
embedding VECTOR(1536),
metadata JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- HNSW index - fast approximate search, higher memory usage
-- Best for: high-throughput, low-latency queries
CREATE INDEX ON documents USING hnsw (embedding vector_cosine_ops)
WITH (m = 16, ef_construction = 64);
-- IVFFlat index - lower memory, slower build, good for batch workloads
-- CREATE INDEX ON documents USING ivfflat (embedding vector_cosine_ops)
-- WITH (lists = 100);
-- Query: top-5 most similar documents with metadata filter
SELECT id, content, metadata,
1 - (embedding <=> $1::vector) AS similarity
FROM documents
WHERE metadata->>'category' = 'product' -- Filter before ANN search
ORDER BY embedding <=> $1::vector
LIMIT 5;
Production Tuning
- HNSW parameters:
m=16(graph connectivity) andef_construction=64(build quality) are good defaults. Increaseef_searchat query time to trade latency for recall:SET hnsw.ef_search = 100; - Dimensionality: Use the smallest embedding model that meets your quality bar. 1536-dim (text-embedding-3-small) is often sufficient and half the storage of 3072-dim.
- Filter selectivity: Pre-filter with indexed JSONB columns before the ANN search. A filter that reduces candidates to <10% of the collection drastically improves both speed and precision.
- Index maintenance: HNSW indexes don't need manual maintenance. IVFFlat lists should be re-created when the dataset grows >10× initial size.