Vector Index Trade-offs

pg_ripple supports hybrid SPARQL + semantic search via the pg_ripple.hybrid_search() function, which uses pgvector's ANN (Approximate Nearest Neighbour) indexes. Two index types are available — HNSW and IVFFlat — at three precision levels: single (32-bit float), half (16-bit float), and binary (1-bit).

This page presents reference benchmarks measured on a 100,000-embedding fixture with 128-dimensional vectors. Use these figures to choose the right combination for your workload.

Benchmark Setup

ParameterValue
Dataset size100,000 embeddings
Dimensions128 (use 1536 for text-embedding-3-small)
Queries1,000 random query vectors
k (neighbours)10
PostgreSQL18
pgvector0.7.4
Hardware8-core CPU, 32 GB RAM

Run the benchmark yourself:

psql -U postgres -f benchmarks/vector_index_compare.sql

Reference Results

HNSW (m=16, ef_construction=64)

PrecisionBuild timeRecall p50Recall p95Latency p50Latency p95
single (32-bit)~45 s99.2%98.1%0.4 ms0.8 ms
half (16-bit)~30 s98.7%97.5%0.3 ms0.6 ms
binary (1-bit)~8 s91.3%88.0%0.08 ms0.15 ms

IVFFlat (lists=100)

PrecisionBuild timeRecall p50Recall p95Latency p50Latency p95
single (32-bit)~5 s96.4%94.2%0.9 ms2.1 ms
half (16-bit)~4 s95.8%93.7%0.7 ms1.8 ms
binary (1-bit)~1.5 s85.2%81.0%0.2 ms0.5 ms

Recommendations

ScenarioRecommended
High-accuracy semantic search (RAG)HNSW, single precision
Latency-sensitive real-time searchHNSW, half precision
Very large datasets (> 10 M embeddings), memory-constrainedIVFFlat, half precision
Coarse pre-filtering before exact rerankingHNSW or IVFFlat, binary
Fast prototyping / developmentIVFFlat, single precision (fast build)

Configuring the Index Type

Control the index type and precision via GUCs:

SET pg_ripple.embedding_index_type = 'hnsw';   -- or 'ivfflat'
SET pg_ripple.embedding_precision = 'single';  -- or 'half' or 'binary'

Rebuild the index after changing:

SELECT pg_ripple.rebuild_embedding_index();

Memory Footprint

PrecisionMemory per 1 M 1536-dim vectors
single (32-bit)~6 GB
half (16-bit)~3 GB
binary (1-bit)~190 MB

For production deployments with millions of embeddings, half precision offers the best recall-to-memory trade-off.