pgvector: Fewer dimensions are better
Lower-dimensional embedding models can match or beat OpenAI's 1536-dimension text-embedding-ada-002 on the MTEB leaderboard while making pgvector queries much cheaper, since fewer dimensions mean fewer distance computations and smaller indexes that fit in RAM. In a benchmark on a 2vCPU/8GB Postgres 15 instance with 224k Wikipedia embeddings and an IVF index (lists=1000), 384-dimension all-MiniLM-L6-v2 delivered 78% more queries per second than ada-002 at accuracy@10 of 0.99 and used about 4GB of RAM instead of 7.5GB. gte-small, also 384 dimensions, reached the same accuracy with probes=10 and more than tripled throughput over MiniLM. The recommendation is to choose models by MTEB score, model size, sequence length, dimensions and language support, and to avoid PCA or t-SNE for shrinking vectors because they lose semantic structure and drift as the data changes.
Related posts
- Matryoshka embeddings: faster OpenAI vector search using Adaptive Retrieval
Supabase mediumAdeptOpenAI's text-embedding-3 models are trained with Matryoshka Representation Learning, so an embedding can be shortened by truncating trailing dimensions and renormalizing, which reproduces the API's `dimensions` output. Adaptive Retrieval exploits this with a two-pass search: a fast HNSW-indexed ANN pass on a low-dimensional prefix fetches an oversized shortlist, then exact KNN on the full 3072d vectors re-ranks it. Benchmarks on 1M dbpedia embeddings found a 512d first pass (ef_construction=400, m=32, ef_search=200, limit = top_k × 8) reached 99% accuracy against 3072d KNN at about 580 QPS. By comparison, a single pass on 1536d vectors topped out near 89%. The post finishes with a Postgres/pgvector implementation using a sub_vector SQL function.
- pgvector 0.4.0 performance
Supabase mediumAdeptWith tuned settings, pgvector 0.4.0's IVFFlat index handles 1M OpenAI embeddings (1536 dimensions, dbpedia dataset) at about 1800 QPS with 0.91 accuracy@10 on a 64-core, 256 GB instance, or about 670 QPS at 0.98 accuracy. Using the ANN Benchmarks methodology, the tests reproduce a default-config pgvector vs Qdrant comparison. Pre-warming RAM, using inner-product distance, raising lists to 2000 and increasing probes makes pgvector competitive, and throughput scales predictably with instance size. Practical guidance: raise lists above the recommended rows/1000 for faster queries at the cost of longer index builds and more maintenance_work_mem, prefer inner product for normalized embeddings, and benchmark with real rather than random vectors before right-sizing RAM.
- 20x faster than pgvector: introducing pg_embedding extension for vector search in Postgres and LangChain
Neon mediumAdept
pg_embedding brought HNSW graph-based approximate nearest neighbor indexing to Postgres. On the GIST-960 dataset (1M 960-dim vectors, k=100, 4 vCPU/16 GB), it ran 5–30x faster than pgvector's IVFFlat at equal recall. IVFFlat needs more probes to raise recall and drifts toward a sequential scan, while HNSW's layered graph gives roughly logarithmic search. HNSW trades higher memory use, slower index builds (driven by efConstruction) and L2-only distance for that speed. Neon has since deprecated pg_embedding in favor of pgvector, which now supports HNSW natively.
- Don’t use vector. Use halvec instead and save 50% of your storage cost
Neon mediumAdept
pgvector 0.7's half-precision halfvec type stores embedding components as 16-bit floats instead of 32-bit, cutting table and HNSW index storage nearly in half. On a 1M-row, 1536-dimension DBpedia dataset on an 8 CPU Neon Postgres instance (HNSW m=32, ef_construction=256), it also reduced index build time by 23% and prewarming time by 50%, with equivalent query latency and recall. Binary quantization shrinks vectors 32x and speeds index builds, but its recall on 1536-dimension embeddings was too low for production. The recommendation is to prefer halfvec over vector after testing on your own data.
- pgvector v0.5.0: Faster semantic search with HNSW indexes
Supabase mediumAdeptpgvector v0.5.0 adds HNSW indexes, which combine skip-list-style layering with navigable small world proximity graphs to do approximate nearest-neighbor search over embeddings. In Supabase benchmarks on 1536-dimension OpenAI vectors, HNSW delivered about 3x the QPS of IVFFlat on 224K vectors and over 6x on 1M vectors at equal accuracy. Tuning ef_search, m and ef_construction trades speed against recall; raising ef_construction to 80 reached 0.99 accuracy@10 with ef_search 100 and 35% more QPS. HNSW can be built on an empty table and stays optimal as data arrives, but it builds more slowly and uses more memory than IVFFlat, whose build times dropped over 50% thanks to parallel list assignment and float-based FMA distance math.