Deploy Supabase Vector

pgvector embeddings and similarity search in Supabase

Deploy Supabase Vector

Just deployed

/app/snippets

/var/lib/postgresql/data

Just deployed

/var/lib/storage

Deploy and Host self hosted Supabase Vector (Self-Hosted Supabase Vector Database with pgvector) on Railway

This template deploys a full self-hosted Supabase stack with pgvector ready to go.

About Hosting Supabase Vector open-source software on Railway (self hosted Supabase vector search with pgvector template)

Your embeddings live in the same Postgres as your app tables, auth users and row level security policies, so there is no second vector database to sync.

Railway handles the containers, private networking, generated secrets and the public gateway.

Why Deploy Supabase Vector, the Pinecone alternative on Railway (Railway Free Trial)

Pinecone is a managed vector database, so your embeddings sit outside the Postgres that holds your app data and users.

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying Supabase Vector on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.

Railway vs Other Hosting Providers and VPS for Supabase Vector self hosting

Choosing where the nine services and their volumes run changes the trade-offs.

ProviderWhat You Get with RailwayWhat You Get with the Other Provider
DigitalOceanA one-click template that wires the services, secrets, and domains for you.A Droplet you manage yourself, including Docker, the .env, and the firewall.
AWSServices linked on Railway with no VPC or IAM setup before the first request.Deep control over networking and backups, with a lot of console work first.
HetznerManaged deploys, volumes, and redeploys handled for you at a higher monthly cost.Cheap servers with generous RAM per euro, if you're happy running Compose yourself.

Pick Railway when you want a working stack fast, and a VPS when cost per gigabyte of RAM matters more.

Common Use Cases for hosted Supabase Vector

  • Semantic search over help articles: Embed each article once and store the vectors beside the text. Users can search by meaning, so "my card got declined" finds the billing article.
  • RAG retrieval for a chatbot: Chunk your manuals, embed the chunks, and call match_documents with the user's question. The top passages go into the prompt, so answers come from your content.
  • Per-user document search protected by RLS: Store each user's embedded chunks and turn on Row Level Security. One user never sees another's rows, even on the same similarity query.
  • Recommendations from embedding similarity: Embed product descriptions and query the nearest neighbours of an item the user just viewed. That gives you "more like this" without a separate model.
  • Hybrid keyword plus vector search: Combine a full-text query with vector ordering in one SQL function, so part numbers and error codes still match alongside fuzzy questions.

Dependencies for Supabase Vector Docker hosted on Railway

This template runs the official Supabase self-hosted stack as nine linked Railway services, and the vector work happens inside the db service.

Deployment Dependencies for Managed Supabase Vector Service (Vector Database)

  • db: supabase/postgres 17.6.1.136 on a volume, with pgvector included. Enable it with create extension vector with schema extensions.
  • supabase (public gateway): Envoy v1.39.1 on port 8000, routing /rest/v1 to PostgREST, /auth/v1 to Auth, /functions/v1 to Edge Functions, and / to Studio behind HTTP basic auth.
  • rest: postgrest v14.17, which serves your match_documents function on /rest/v1/rpc.
  • Storage volume: the storage service keeps files at /var/lib/storage, with a 50 MB file size limit.

Implementation Details for Supabase Vector (Using Supabase official docker image)

The deploy generates JWT_SECRET, POSTGRES_PASSWORD, DASHBOARD_PASSWORD (username supabase) and the other keys.

Set your embedding dimension once you pick a model.

How does Supabase Vector compare against other vector databases for AI apps

Supabase vs Pinecone (Pinecone Alternative)

  • Where Supabase wins: Vectors sit in the same Postgres as your users and documents, so one query can filter by owner and rank by similarity with no second system to sync.
  • Where Pinecone wins: It is fully managed, with no database to size, patch or back up, which asks less of a small team.
  • Cost shape: Self hosted on Railway you pay for compute and volume, not per index or per query.

Supabase vs Qdrant (Qdrant Alternative)

  • Where Supabase wins: You get pgvector SQL joins, auth, storage and REST APIs in one stack instead of building those layers around a vector store.
  • Where Qdrant wins: It is purpose built for vector search, with richer payload filtering, and can pull ahead on very large collections with aggressive recall targets.
  • Operational note: Qdrant is one service to run, while this template is nine, so expect more moving parts.

Supabase vs Weaviate (Weaviate Alternative)

  • Where Supabase wins: Plain SQL, Postgres transactions and familiar migrations mean your team already knows how to query and change the data.
  • Where Weaviate wins: It bundles vectorizer and reranker modules, saving you from wiring up embedding calls yourself.
  • Honest tradeoff: With Supabase you generate embeddings in your app or an Edge Function.

Supabase vs plain Postgres with pgvector (pgvector Alternative)

  • Where Supabase wins: Auth, the REST API, Studio, realtime and storage come around the same pgvector extension, so you skip writing that glue.
  • Where plain Postgres wins: It has fewer services to run, and a bare install is simpler if you only need vector columns.
  • Practical point: Enabling pgvector with create extension vector with schema extensions works the same in both, so you can start plain and move later.

How to use Supabase Vector (the OSS backend platform)?

Work through these steps on day one after deploy.

  1. Log into Studio on your Railway Supabase domain with supabase and DASHBOARD_PASSWORD.
  2. Enable pgvector in the SQL editor.
create extension vector with schema extensions;
  1. Create a documents table with an embedding column sized to your model (384 matches gte-small).
create table documents (
  id bigint primary key generated always as identity,
  content text,
  embedding extensions.vector(384)
);
  1. Insert rows with embeddings from your model.
  2. Create match_documents, ordering by cosine distance with to.
create or replace function match_documents (
  query_embedding extensions.vector(384),
  match_threshold float,
  match_count int
)
returns table (id bigint, content text, similarity float)
language sql stable security invoker
as $$
  select id, content, 1 - (embedding <=> query_embedding) as similarity
  from documents
  where 1 - (embedding <=> query_embedding) > match_threshold
  order by embedding <=> query_embedding
  limit match_count;
$$;
  1. Call it from supabase-js with rpc.
const { data, error } = await supabase.rpc('match_documents', {
  query_embedding: embedding,
  match_threshold: 0.78,
  match_count: 5,
})
  1. Add an HNSW index for speed as the table grows.
create index on documents using hnsw (embedding extensions.vector_cosine_ops);
  1. Turn on Row Level Security with alter table documents enable row level security; before browser clients read the table.

How to self host Supabase Vector on other VPS Services (Supabase self hosting guide)

Clone the Repository

Clone the upstream Supabase repository, which holds the Docker setup this template is built from.

git clone --depth 1 https://github.com/supabase/supabase
cd supabase/docker

Install Dependencies

You need Docker and the Compose plugin on the VPS, with at least 4 GB of RAM.

docker compose pull

Configure Environment Variables

Copy the example env file and replace every secret before booting.

cp .env.example .env

Start the Supabase Vector Application

Start the stack in the background, then open Studio on your-domain and log in.

docker compose up -d

Official Pricing of Supabase Vector (Supabase pricing)

Supabase Vector is open source under Apache-2.0, so the software is free.

Supabase Vector cloud vs self hosted comparison (Pricing, features, costs, and more)

Self-hosting Supabase is free as a license, so your real cost is the Railway bill and the time you spend keeping it running.

Monthly cost of self hosting Supabase Vector on Railway

Expect roughly 20 to 40 USD a month at light use across the nine services and their volumes.

System Requirements for Hosting Supabase Vector on a VPS

Upstream recommends at least 4 GB of RAM, which is a floor rather than a comfortable target once you add embeddings.

Frequently Asked Questions (FAQs)

Which embedding size should I pick for my vector column?

Match the column to your embedding model's output dimensions, such as 384 for gte-small or 1536 for many OpenAI models.

Should I use HNSW or IVFFlat for the index?

Use HNSW unless you have a reason not to.

Why does my filtered search return fewer rows than I asked for?

Approximate indexes scan a limited candidate set, so a filter on another column can remove most of those candidates before the limit applies.

Can Edge Functions create the embeddings?

Yes.

How much RAM do the vector indexes need?

HNSW indexes live mostly in memory, so size Postgres RAM to hold the index alongside your normal working set.

Does Row Level Security apply to vector search?

It does when the table has RLS enabled and your match function runs as security invoker.


Template Content

More templates in this category

View Template
RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set
S3-compatible object store, keys and public URL preset, volume kept

SuperSlowSloth
0
View Template
TimescaleDB
A PostgreSQL-based time-series database for analytics on Railway.

Rakit
1
View Template
Garage S3 Storage
Ultra-light S3 server: fast, open-source, plug-and-play.

PROJETOS
8