---
title: "Hosting Postgres with pgvector: provider tradeoffs, migrations, indexes, and tuning"
description: "Running pgvector well depends on hosting that allows extension and configuration control, migrations wired into the deploy pipeline, and the right index choice."
url: "https://swe.quest/articles/hosting-postgres-with-pgvector-provider-tradeoffs-migrations-indexes-and-tuning-5801c10912bf8686"
canonical: "https://blog.railway.com/p/hosting-postgres-with-pgvector"
source: "Railway"
published: "2025-12-15"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["postgres","vector-search","schema-migrations","performance"]
---

# Hosting Postgres with pgvector: provider tradeoffs, migrations, indexes, and tuning

A post on [Railway](https://swe.quest/sources/railway.md), published 2025-12-15, 9 min read, How-to. Original: [https://blog.railway.com/p/hosting-postgres-with-pgvector](https://blog.railway.com/p/hosting-postgres-with-pgvector)

## Summary

Running pgvector well depends on hosting that allows extension and configuration control, migrations wired into the deploy pipeline, and the right index choice. Run migrations as pre-deploy steps, use idempotent CREATE EXTENSION, and build vector indexes with CREATE INDEX CONCURRENTLY outside a transaction so large tables stay writable. HNSW is recommended over IVFFlat for most workloads because recall and latency stay steadier, and tuning maintenance\_work\_mem, work\_mem and effective\_cache\_size helps builds and queries. For traffic spikes, pair connection pooling, caching, precomputation and LIMIT queries with scalable infrastructure. Railway's container-based Postgres offers full extension control but lacks point-in-time recovery, automatic failover and built-in read replicas.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Vector search](https://swe.quest/tags/vector-search.md) (Data & databases)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- PostgreSQL basics ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- vector embeddings ([easy posts on RAG & retrieval](https://swe.quest/tags/rag.md?difficulty=easy))
- database migrations ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))

## Keywords

pgvector, PostgreSQL, HNSW, IVFFlat, Railway, PgBouncer, Prisma

## Related posts

- [pgvector: 30x Faster Index Build for your Vector Embeddings](https://swe.quest/articles/pgvector-30x-faster-index-build-for-your-vector-embeddings-cd6dabfa49eb13de.md): Neon · 2024-02-07 · Medium · 6 min read · Vector search, PostgreSQL, Performance engineering
  pgvector 0.6.0 adds parallel builds for HNSW indexes, cutting build time by up to 30x in benchmarks on 10M 1,536-dimension vectors using a 64 vCPU, 512GB instance.
- [RAG With Autoscaling: Better Performance With Lower Costs For pgvector](https://swe.quest/articles/rag-with-autoscaling-better-performance-with-lower-costs-for-pgvector-52ce2e1857682b4f.md): Neon · 2024-08-27 · Medium · 4 min read · Vector search, PostgreSQL, Capacity planning, RAG & retrieval, Cost optimization
  Neon's autoscaling lets a Postgres instance scale up temporarily for the heavy memory and CPU demands of pgvector HNSW index builds, then scale back down, instead of being permanently overprovisioned.
- [pgvector 0.4.0 performance](https://swe.quest/articles/pgvector-0-4-0-performance-559fc540f926a562.md): Supabase · 2023-07-13 · Medium · 8 min read · Vector search, PostgreSQL, Performance engineering, Inference & serving
  With tuned settings, pgvector 0.4.0's IVFFlat index handles 1M OpenAI embeddings (1536 dimensions, dbpedia dataset) at about 1800 QPS with 0.91 accuracy@10 on a 64-core, 256 GB instance, or about 670 QPS at 0.98 accuracy.
- [pgvector 0.6.0: 30x faster with parallel index builds](https://swe.quest/articles/pgvector-0-6-0-30x-faster-with-parallel-index-builds-e5dea50876a1e20f.md): Supabase · 2024-01-30 · Medium · 3 min read · Vector search, PostgreSQL, Performance engineering
  pgvector 0.6.0 adds parallel HNSW index builds, cutting build time for 1M 1536-dimension vectors (dbpedia OpenAI dataset, m=16, ef\_construction=200) from about 1h27m to 9.5 minutes.
- [20x faster than pgvector: introducing pg\_embedding extension for vector search in Postgres and LangChain](https://swe.quest/articles/20x-faster-than-pgvector-introducing-pg-embedding-extension-for-vector-search-058737fc9388f495.md): Neon · 2023-07-11 · Medium · 7 min read · Vector search, PostgreSQL, Performance engineering
  pg\_embedding brought HNSW graph-based approximate nearest neighbor indexing to Postgres.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
