Railway

Deploy PostgreSQL with pgvectorscale

PostgreSQL 18 with pgvector and pgvectorscale extensions.

Deploy PostgreSQL with pgvectorscale

/var/lib/postgresql/data

Deploy and Host PostgreSQL with pgvectorscale on Railway

PostgreSQL 18 with pgvector and pgvectorscale extensions for high-performance vector similarity search with StreamingDiskANN indexing, providing superior performance for AI/ML applications requiring embeddings storage and semantic search capabilities.

About Hosting PostgreSQL with pgvectorscale

pgvectorscale extends pgvector with advanced indexing algorithms like StreamingDiskANN, offering better performance and scalability for vector similarity search. This template provides a production-ready PostgreSQL 18 database with both extensions pre-installed and configured. Built on Railway's official postgres-ssl image, it ships SSL out of the box with auto-generated certificates, pgBackRest WAL archiving with point-in-time recovery support, automatic extension initialization and updates, and persistent volume storage. Images are published under immutable version tags and smoke-tested in CI before release. Perfect for RAG applications, semantic search, recommendation systems, and any AI application requiring efficient vector operations at scale.

Common Use Cases

  • RAG (Retrieval Augmented Generation): Store and retrieve document embeddings for AI chatbots and question-answering systems
  • Semantic Search: Build intelligent search engines that understand context and meaning beyond keyword matching
  • Recommendation Systems: Power personalized recommendations using vector similarity between user preferences and content
  • Image & Video Search: Enable visual similarity search for media libraries and content discovery platforms
  • Anomaly Detection: Identify outliers in high-dimensional data for fraud detection and monitoring systems

Dependencies for PostgreSQL with pgvectorscale Hosting

  • Docker: Container runtime for building and running the PostgreSQL image

Deployment Dependencies

Implementation Details

Connecting to your database:

import psycopg2
from pgvector.psycopg2 import register_vector

conn = psycopg2.connect(DATABASE_PUBLIC_URL)
register_vector(conn)

# Create a table with vector column
cur = conn.cursor()
cur.execute("""
    CREATE TABLE items (
        id SERIAL PRIMARY KEY,
        embedding vector(1536)
    )
""")

# Create StreamingDiskANN index
cur.execute("""
    CREATE INDEX ON items
    USING diskann (embedding)
    WITH (num_neighbors=50)
""")

Environment Variables:

  • POSTGRES_PASSWORD: Database password (required)
  • POSTGRES_USER: Database username (default: postgres)
  • POSTGRES_DB: Database name (default: railway)
  • PGDATA: Data directory (default: /var/lib/postgresql/data/pgdata)

Volume Configuration: Mount a volume at /var/lib/postgresql/data for persistent storage.

Why Deploy PostgreSQL with pgvectorscale 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 PostgreSQL with pgvectorscale 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
Garage S3 Storage
Ultra-light S3 server: fast, open-source, plug-and-play.

PROJETOS
7
View Template
NEW
Redis
Self Host Latest Redis with Railway

Arloodots
0
View Template
Postgres Backup to Cloudflare R2 (S3-Compatible)
Automated PostgreSQL backups to S3-compatible storage with encryption

Artour
7