Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Supabase 5 min read Research mediumAdept

pgvector vs Pinecone: cost and performance

On a ~$410/month Supabase 2XL instance (8-core ARM, 32 GB RAM) with an HNSW index (m=36, ef_construction=128), pgvector delivered far higher throughput than budget-matched (~$480/month) Pinecone setups on 1M OpenAI 1536-d dbpedia embeddings. At matched accuracy@10 it handled about 12x the QPS of six s1 pods and over 4x that of three p1.x2 pods. It was also faster than Pinecone's p2 pods even at 0.99 accuracy versus their 0.94. Pinecone accuracy was measured against pgvector exact KNN results because Pinecone exposes no exact search, and Pinecone can still be cheaper for low-QPS workloads on a single unreplicated pod.

Related posts

  • pgvector 0.4.0 performance

    Supabase mediumAdept

    With 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.

  • pgvector v0.5.0: Faster semantic search with HNSW indexes

    Supabase mediumAdept

    pgvector 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.

  • 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.

  • pgvector 0.6.0: 30x faster with parallel index builds

    Supabase mediumAdept

    pgvector 0.6.0 adds parallel HNSW index builds, cutting build time for 1M 1536-dimension vectors (dbpedia OpenAI dataset, m=16, ef_construction=200) from about 1h27m to 9.5 minutes. Benchmarks show 7-9x speedups on a 16-core instance and up to 13.5x on 64 cores, with no change in recall (0.963) or QPS. Scaling is not linear in core count, so max_parallel_maintenance_workers is best set to about CPU count / 2. Building on unlogged tables skips the non-parallelizable WAL write and pushes speedups to 23-31x, which suits embeddings that can be regenerated from source data.

  • Storing OpenAI embeddings in Postgres with pgvector

    Supabase mediumAdept

    pgvector adds a vector data type and distance operators (Euclidean <->, negative inner product <#>, cosine <=>) to Postgres, so OpenAI text-embedding-ada-002 embeddings (1536 dimensions) can be stored and queried for similarity directly in the database. The walkthrough creates a documents table, a match_documents SQL function that filters by a cosine-similarity threshold, and an IVFFlat index sized at roughly 4 * sqrt(rows) lists. It then generates embeddings in JavaScript and builds Deno Edge Functions for semantic search and for retrieval-augmented answers with text-davinci-003, keeping injected context under about 1500 tokens to fit the 4000-token limit.

The quest for software engineering knowledge.

Look:
Layout: