Similarity search takes seconds Because there are no vector indexes on your embeddings

You stored your embeddings in pgvector but similarity search takes seconds. The table has no HNSW or IVFFlat index, so every query falls back to a sequential scan over every vector.

  • Target: similarity search under 200ms
  • Fix shipped in 30 days
  • Slow Current similarity search time
  • No index Embeddings with no vector index
  • <200ms Target search time after optimization

How it shows up

For teams whose vector search is unusable because of missing indexes, oversized embeddings, and unoptimized query patterns. pgvector is fast when configured correctly. These are the three configuration issues that make it unusable.

What this sprint fixes

  • Slow similarity search from missing vector indexes
  • Every embedding scanned sequentially on every query
  • 1536-dimension embeddings when far fewer dimensions would do

No vector index: a sequential scan on every row

Without an HNSW or IVFFlat index, every similarity query scans every embedding. That is gigabytes of sequential reading per query, multiplied by every query per second, for a search that a graph index answers far faster. EXPLAIN ANALYZE shows the Seq Scan; the fix is one CREATE INDEX with the right opclass.

Oversized embeddings: 1536 dimensions at 6KB each

OpenAI's text-embedding-3-small produces 1536 dimensions, and text-embedding-3-large defaults to 3072. For many retrieval tasks, a smaller model with far fewer dimensions keeps nearly the same recall. Fewer dimensions mean faster distance calculations and smaller indexes. text-embedding-3 also supports Matryoshka shortening via the dimensions parameter, so you can trim without re-embedding from scratch.

Wrong distance function: cosine on already-normalized vectors

Your queries use cosine distance (vector_cosine_ops) but OpenAI embeddings already ship normalized to length 1. On normalized vectors, inner product (vector_ip_ops, the <#> operator) returns identical rankings and skips the redundant norm calculation. The gain is modest at small scale but real at high query volume, and the index opclass must match the query operator or PostgreSQL silently falls back to a sequential scan.

Who it is for

Best fit when you have embeddings in Supabase but similarity search is too slow for user-facing features.

Good fit

  • Teams with a growing embeddings table and no vector index
  • Applications where similarity search takes over a second
  • RAG implementations with slow retrieval degrading AI response time

Why pgvector setups underperform

Tutorials show you how to store vectors.

Repeated failure patterns

  • Following a tutorial that works with a demo dataset but collapses at production size
  • Using the default OpenAI model at full dimensions without evaluating smaller, faster alternatives
  • Building an IVFFlat index on near-empty data, or leaving probes at the default of 1 so recall is terrible

What we do in 30 days

We index, tune, and optimize pgvector for your specific query patterns and recall requirements.

  1. Days 1-5: Benchmarking

    Measure current performance. Analyze query patterns: how many queries per second, what recall level is acceptable, how often embeddings are updated. These determine the optimal index type and parameters.

  2. Days 6-14: Index and distance optimization

    Build an HNSW or IVFFlat index with m and ef_construction tuned for your data, then dial ef_search at query time to hit your recall target. Switch to inner product (vector_ip_ops) if vectors are normalized. Proof release target: search under 200ms with required recall, verified against an exact-search ground truth set.

  3. Days 15-24: Embedding and query optimization

    Evaluate dimension reduction using PCA or a smaller embedding model. Optimize RPC functions for batched queries. Add pre-filtering with metadata to reduce scan scope.

  4. Days 25-30: Monitoring and handoff

    Performance monitoring for vector search latency and recall. Index maintenance procedures. Guide for adding new vectors without degrading performance.

What you get

Fast vector search with proper indexing, tuned parameters, and monitoring.

Performance improvements

  • Target: search time under 200ms
  • HNSW or IVFFlat index tuned for your query patterns
  • Optimal distance function selected and configured

Operations

  • Vector search latency monitoring
  • Index maintenance procedures and schedule
  • Guide for adding vectors without degrading performance

Why Pineido

We tune for your data, not generic benchmarks.

Data-specific tuning

HNSW m, ef_construction, and ef_search are not one-size-fits-all, and over-provisioning m mostly buys longer build times with negligible recall gains. We benchmark multiple configurations against your actual data, comparing each against an exact-search ground truth set to find the settings that hit your recall target fastest.

Slow Current similarity search time

Fix your pgvector search in 30 days

Target: under 200ms, down from seconds.

Fixed scope, fixed price.

You leave with

  1. We benchmark current performance and analyze query patterns within 5 days
  2. Vector index built and tuned, targeting search under 200ms by day 14

Direct answers before you commit

Should we use HNSW or IVFFlat?

HNSW is faster for queries, scales recall sublinearly, and can be built before the table is fully loaded. IVFFlat is faster to build and uses less memory, but it needs representative data present at build time and is best for large, mostly-static sets. For most Supabase applications, HNSW is the better choice. We benchmark both on your data to verify.

Should we switch to a dedicated vector database like Pinecone?

Usually not. Unless you have a very large vector set or need extremely low latency, properly indexed pgvector holds its own against Pinecone. Keeping vectors in Supabase means no additional infrastructure, no data sync, and lower cost.

Will reducing dimensions hurt search quality?

We benchmark recall at both dimension levels with your actual queries. Fewer dimensions usually cost a little recall and buy a lot of speed. We show you the tradeoff with your data before making the change.

How do you handle index build time on large tables?

An HNSW index build on a large table can take a while, depending on row count and dimensions. We build the index during a maintenance window or on a replica first. Your application continues serving queries during the build. Once the index is ready, queries switch to it with zero downtime.

Can pgvector handle hybrid search combining text and semantic results?

Yes. Following Supabase's documented pattern, we implement reciprocal rank fusion that merges pgvector similarity ranks with PostgreSQL full-text search (tsvector) ranks using the 1/(k + rank) formula, k defaulting to 50. Because it fuses ranks rather than incompatible raw scores, the result ranks documents by both keyword relevance and semantic meaning, catching exact matches like error codes and product names that pure vector search misses. This hybrid approach consistently outperforms either method alone, with no extra infrastructure since it is all SQL.

What embedding model should we use?

It depends on your use case. OpenAI text-embedding-3-small works well for general content at low cost. Cohere embed-v3 excels at multilingual search. For domain-specific data, a fine-tuned model may outperform both. We benchmark candidates on your actual queries and recommend based on quality and cost.

ByFounder and Imaginator

Published Updated