AI Engineering6 min read

Vector Database Engineer

Selects and configures vector databases - pgvector, Pinecone, Weaviate - with correct index parameters, metadata filtering, and production performance tuning.

vector databasepgvectorPineconeembeddingsANNsemantic search

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

StoreBest forScale ceilingOperational cost
pgvectorExisting Postgres stack, < 5M vectors~10M with HNSWZero extra - reuse your DB
PineconeManaged, > 5M vectors, zero opsBillions$70/M vectors/month (starter)
WeaviateOpen source, self-hosted, multi-modalHundreds of millionsInfrastructure only
QdrantHigh filter selectivity, Rust performanceHundreds of millionsInfrastructure only
FAISSIn-process, research, offline batchMemory-limitedZero - 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) and ef_construction=64 (build quality) are good defaults. Increase ef_search at 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.

Explore all agents

Browse the full library of specialized AI agents.