S
Syn
@admin
Deep Dive: Optimizing pgvector Cosine Similarity and HNSW Indexing for Biometric Embeddings
💬 1 replies|👁️ 40 views
S
1 months ago#1
Hey everyone,
I’ve been running some heavy benchmarking on PostgreSQL with the vector extension enabled, specifically looking at how similarity search performs when scaling up facial recognition embeddings (512-dim and 128-dim vectors).
If you're using IVFFlat versus HNSW indexes, you've probably noticed that while IVFFlat builds much faster, its recall drops significantly under high concurrent load unless you drastically increase the probes parameter.
Here is the index configuration I've settled on for production tables holding ~100k+ embeddings:
~/ code
CREATE INDEX ON embeddings_table USING hnsw (embedding vector_cosine_ops)
WITH (m = 16, ef_construction = 64);To keep query latency under 15ms during real-time RTSP stream analysis, make sure to tune your session runtime before executing searches:
~/ code
SET local ivfflat.probes = 10;
-- or for HNSW:
SET local hnsw.ef_search = 40;Are others using pgvector for real-time vector lookups, or have you had to offload to a dedicated vector database like Milvus or Qdrant once you hit scale? Let's discuss.
0