Deploy pgvector-pg18

PostgreSQL 18 with powerful vector search support.

Deploy pgvector-pg18

pgvector

pgvector/pgvector:pg18

Just deployed

/var/lib/postgresql/data/

Deploy and Host pgvector-pg18 on Railway

TL;DR: This template is like the existing pgvector template, but with PostgreSQL v18 instead of PostgreSQL v16.

What is PGVector?

PGVector is an extension for PostgreSQL that enables efficient storage and retrieval of vector embeddings, making it ideal for machine learning and AI applications like similarity search. It adds support for vector data types and indexing methods to facilitate quick querying on high-dimensional vectors.

About Hosting pgvector-pg18

This template provides PostgreSQL v18 with the pgvector extension pre-installed. You’ll need to enable the pgvector extension in each database where you intend to use it.

  1. Connection Setup:

    • Find the appropriate connection string under the service variables tab:
      • DATABASE_URL: Used for connecting from other Railway services.
      • DATABASE_PUBLIC_URL: Used for connecting from external services/tools.
    • Reference these URLs in your other services variables as needed (For instance, ${{ pgvector.DATABASE_URL }})
  2. Enabling PGVector Extension: Before using pgvector, you must enable the extension in your database:

    CREATE EXTENSION IF NOT EXISTS vector;
    

Common Use Cases

  • NLP Applications (Semantec text search, RAG applications)
  • Similarity Search (Similar item recommendations, Related documents)
  • Image Similarity Search (Visual similarity, Product image matching)
  • Anomaly Detection (Fraud detection, Log analysis)

Example Usage Script

Here’s a simple example to verify that the pgvector extension is set up and working as expected:

CREATE EXTENSION IF NOT EXISTS vector;

-- Create a table with an embedding vector
CREATE TABLE items (
    id bigserial PRIMARY KEY,
    embedding vector(3)
);

-- Insert some example data
INSERT INTO items (embedding) VALUES 
('[1,2,3]'), 
('[4,5,6]');

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

This SQL snippet sets up the pgvector extension, creates a table, inserts data, and runs a basic similarity query using the <-> operator to measure vector distance.

Dependencies for pgvector-pg18 Hosting

The Railway template includes the required dependencies with pre-configured deployment settings.

Deployment Dependencies

For more details on PGVector, visit the official GitHub repository: github.com/pgvector/pgvector

Why Deploy pgvector-pg18 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-pg18 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
Postgres-to-R2 Backup
Auto back up PostgreSQL databases to Cloudflare R2 with optional encryption

View Template
ReadySet
A lightweight caching engine for Postgres

View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.