Deploy pgvector-pg19

PostgreSQL 19 vector database for AI: embeddings, RAG, semantic search

Deploy pgvector-pg19

Just deployed

/var/lib/postgresql/data/

Deploy and Host pgvector-pg19 on Railway

pgvector-pg19 is PostgreSQL 19 with the pgvector extension built in: a vector database for AI where embeddings, RAG and semantic search run in plain SQL, next to the relational rows they describe. It replaces a separate vector store such as Pinecone, Qdrant, Weaviate or Chroma, and with it the second datastore you would otherwise keep in sync, back up and pay for. One click gives you a persistent volume, a generated password, and both a private and a public connection string.

About Hosting pgvector-pg19

This template runs the official pgvector/pgvector:pg19 image as a single Railway service with a persistent volume. The pg19 tag tracks the latest PostgreSQL 19 build - so redeploying the service picks up patch releases automatically.

A public TCP proxy is enabled, to allow connecting from any PostgreSQL client, like psql.

Common Use Cases

  • Retrieval-augmented generation: store document and chunk embeddings, retrieve LLM context, and filter it by tenant, date or permission in the same query
  • Semantic search over text, products, documentation or support history
  • Recommendations and similar-item lookups, joined straight to the product or user table
  • Image and multimodal similarity search over CLIP-style embeddings
  • Deduplication and anomaly detection across high-dimensional data

Dependencies for pgvector-pg19 Hosting

  • pgvector/pgvector:pg19: the official pgvector image (PostgreSQL 19 with the vector extension compiled in).
  • A Railway volume mounted at the PostgreSQL data directory.

Deployment Dependencies

📌 Implementation Details

Getting your connection string: open the pgvector service's Variables tab, then copy the required values.

  • DATABASE_URL is the private URL for services inside the same Railway project.
  • DATABASE_PUBLIC_URL is for connecting from external clients outside of Railway.

Enable the extension once per database, then test it:

CREATE EXTENSION IF NOT EXISTS vector;

CREATE TABLE items (
    id bigserial PRIMARY KEY,
    embedding vector(3)
);

INSERT INTO items (embedding) VALUES
('[1,2,3]'),
('[4,5,6]');

SELECT * FROM items
ORDER BY embedding <-> '[3,1,2]'
LIMIT 5;

Upgrading an existing deployment: new deployments always get the latest pgvector release. An existing deployment keeps running the image it was deployed with, and each database keeps its extension version until you update it. To upgrade:

  1. Redeploy the service: open the pgvector service, go to the Deployments tab, click the three dots on the active deployment and choose Redeploy.

  2. Update the extension in each database where you enabled it:

    ALTER EXTENSION vector UPDATE;
    
  3. Check the version:

    SELECT default_version, installed_version FROM pg_available_extensions WHERE name = 'vector';
    

    default_version is what the image ships and installed_version is what your database uses. Both should match the newest release in the pgvector changelog.

Open Source Vector Databases Compared

Ease of developmentScalabilityCost
This template (Postgres 19 + pgvector)★★★★★ Vectors join and filter like any SQL column, hybrid text + vector search in one query, every Postgres driver and ORM works★★★★☆ Millions of vectors on a single instance; compression, read replicas and sharding beyond that★★★★★ One service and one volume - and it can be your app database at the same time
Qdrant★★★☆☆ Its own REST and gRPC APIs and SDKs; filters on metadata you attach to each vector; no joins★★★★☆ Strong on a single node; billion-scale means a multi-node cluster you operate yourself★★★★☆ One service and volume; built to keep RAM low by using disk
Weaviate★★☆☆☆ Its own schema and GraphQL or REST APIs, via its SDKs★★★☆☆ Memory-bound: plan roughly twice your raw vector size in RAM★★☆☆☆ RAM is the cost driver: same data, larger instance
Chroma★★★★☆ The simplest client to prototype with (Python, JavaScript); metadata filters only★★☆☆☆ Single-node; tested by its own developers to about 7 million embeddings★★★☆☆ Roughly 4 GB of RAM per million embeddings (1,024-dim)
Milvus★★☆☆☆ Its own SDKs; filters on scalar fields★★★★★ Built for distributed clusters and billion-scale datasets★☆☆☆☆ The heaviest: four services (Milvus, etcd, MinIO, REST proxy), at least 4 GB of RAM

Licensing

pgvector is free and open source (PostgreSQL License, which is permissive and puts no obligations on your application). Credit to maintainers: it is built and maintained by Andrew Kane and contributors.

FAQ

Do I lose my vectors when Railway redeploys? No. The database lives on a persistent volume that survives restarts, redeploys and image upgrades.

How many vectors can this handle? Millions on a single instance; RAM sets the ceiling. halfvec storage and binary quantization shrink the working set, and read replicas or Citus sharding take it further.

How many dimensions can I index? The vector type stores up to 16,000 dimensions, but HNSW and IVFFlat index up to 2,000. Cast to halfvec to index up to 4,000, or binary-quantize to bit for up to 64,000. Most embedding models sit between 384 and 1,536 dimensions and index directly; the 3,072-dimension models need the halfvec cast.

Does it need a GPU? No. pgvector runs entirely on CPU; embeddings are generated by your application or model provider, not by the database.

Does it support hybrid search? Yes. Full-text search and vector distance combine in one SQL query; the pgvector README includes a worked reciprocal-rank-fusion example.

Can I use it with LangChain or my ORM? Yes. pgvector ships official Django and SQLAlchemy integrations, LangChain and LlamaIndex both have Postgres vector stores, and anything that speaks Postgres works.

How do I connect from outside Railway? Copy DATABASE_PUBLIC_URL from the Variables tab and run psql "$DATABASE_PUBLIC_URL". The public proxy is on by default; remove it in the service's Settings tab if you want the database reachable only from inside your Railway project.

How do I back up or migrate my data? Vectors are ordinary table data, so pg_dump and pg_restore cover them like everything else: into this template from an existing database, or out to any other Postgres.

Why Deploy pgvector-pg19 on Railway?

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


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
Neo4j 2026.10 Community
Neo4j graph database with APOC, Browser, Bolt TCP proxy and a volume

My Projects
0