Supabase pgvector: Building Vector Search Without the Complexity
Key Takeaways
- •pgvector in Supabase eliminates the need for a separate vector database for most products
- •Under 100K vectors pgvector matches or beats dedicated vector databases in latency
- •Hybrid queries combining vector similarity with relational filters are the killer feature
- •Switch to a dedicated vector DB only when exceeding 1M vectors or needing sub-10ms latency
The Case for Unified Data
The default advice for AI applications is to use a dedicated vector database like Pinecone, Weaviate, or Qdrant. For many teams, this is overkill. If your data already lives in Postgres, adding pgvector to your existing Supabase instance eliminates an entire infrastructure component.
Setting Up pgvector in Supabase
Supabase ships with pgvector enabled by default. Creating a vector column is as simple as:
ALTER TABLE documents ADD COLUMN embedding vector(1536);For similarity search, create an index:
CREATE INDEX ON documents USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);Performance Reality
We have tested pgvector extensively and here are the honest numbers:
- Under 100K vectors: pgvector matches or beats dedicated vector databases in query latency
- 100K-1M vectors: pgvector is competitive with proper indexing (HNSW recommended over IVFFlat)
- Over 1M vectors: Dedicated vector databases start showing advantages in query performance and scaling
For most startups and mid-stage products, you will never hit 1M vectors. Your product documentation, customer support tickets, and knowledge base articles probably total 10K-50K documents.
The Killer Feature: Hybrid Queries
The real advantage of pgvector in Supabase is joining vector similarity with relational filters in a single query. "Find the most similar documents to this query, but only from this customer's workspace, created in the last 30 days, with status = published." Try doing that efficiently with a separate vector database.
When to Use a Dedicated Vector DB
If you have more than 1M vectors, need sub-10ms query latency, or require advanced features like namespaces and metadata filtering at scale, a dedicated solution makes sense.
Frequently Asked Questions
Can Supabase handle vector search?
Yes. Supabase ships with pgvector enabled by default. For most products under 1M vectors, it matches or beats dedicated vector databases and adds the advantage of hybrid relational-vector queries.
When should you use a dedicated vector database instead of pgvector?
Consider a dedicated vector database when you exceed 1M vectors, need sub-10ms query latency, or require advanced features like namespaces and metadata filtering at scale.
What is the advantage of pgvector over Pinecone?
The killer feature is hybrid queries, combining vector similarity with relational filters (customer workspace, date range, status) in a single query without managing a separate database.
