---
title: "Deploy pgvector-pg19"
description: "PostgreSQL 19 vector database for AI: embeddings, RAG, semantic search"
category: "Storage"
url: https://railway.com/deploy/pgvector-pg19
---

# Deploy pgvector-pg19

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

**[Deploy pgvector-pg19 on Railway](https://railway.com/template/pgvector-pg19)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/pgvector-pg19/manifest.json

- **Creator:** ProCode
- **Category:** Storage
- **Total deploys:** 2

## Template content

### pgvector https://devicons.railway.app/i/postgresql.svg

- **Image:** pgvector/pgvector:pg19
- **Start command:** `/bin/sh -c "unset PGPORT; docker-entrypoint.sh postgres --port=5432"`

## Documentation

# 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

- [pgvector on GitHub](https://github.com/pgvector/pgvector)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)

### 📌 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:**

```sql
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:

   ```sql
   ALTER EXTENSION vector UPDATE;
   ```

3. **Check the version:**

   ```sql
   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](https://github.com/pgvector/pgvector/blob/master/CHANGELOG.md).

## Open Source Vector Databases Compared

| | Ease of development | Scalability | Cost |
| --- | --- | --- | --- |
| **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](https://github.com/pgvector/pgvector/graphs/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.


## Similar templates

- [RustFS | (Just Updated) S3 Object Store, Public URL and Keys Set](https://railway.com/deploy/rustfs-or-just-updated-s3-object-store-p) — S3-compatible object store, keys and public URL preset, volume kept
- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — A PostgreSQL-based time-series database for analytics on Railway.
- [Neo4j 2026.10 Community](https://railway.com/deploy/neo4j-202610-community) — Neo4j graph database with APOC, Browser, Bolt TCP proxy and a volume

Open this page in a browser: https://railway.com/deploy/pgvector-pg19
