~/rivestack $ _
PostgreSQL for AI:
one database for
data and vectors.
// Build RAG, semantic search, and recommendations on PostgreSQL with pgvector: embeddings stored next to your relational data, queried in plain SQL. Dedicated NVMe keeps retrieval under 4ms p50, with backups, monitoring, and HA included. No separate vector database to run or keep in sync.
PostgreSQL for AI · pgvector · PostgreSQL 18 · NVMe · EU + US-East + Singapore
# at a glance
- pgvector
- pre-installed on every database
- < 4 ms
- p50 vector search on NVMe
- $29/mo
- dedicated, fixed pricing
- EU
- Hosted in Germany · GDPR-ready
// Every benchmark is measured with pgvector-bench and reproducible. We never publish invented QPS.
# why run AI on PostgreSQL
The database your app already trusts, now doing vector search.
One database for app data and vectors
Keep embeddings next to the rows they describe. Filters, joins, and tenant scoping happen in plain SQL, with no second system to keep in sync, no dual-write consistency bugs, no extra bill. Your AI features and your relational data share one transactional store.
Why managed Postgres for AI →pgvector on NVMe, tuned for RAG
HNSW search is bound by random-read latency. Local NVMe keeps a 250k × 1536 index at ~2 ms single-client p50, recall@10 0.93 (~983 QPS at 4 clients on a Solo node) in our benchmarks, and a Scale node builds and serves a full 1M × 1536 index hot at ~3,600 QPS / p50 ~2.3ms. pgvector ships pre-installed and tuned, so retrieval for RAG and semantic search stays fast as the index grows.
NVMe vs cloud SSD benchmarks →Production-ready by default
Daily backups with point-in-time recovery, optional Patroni HA with automatic failover, and a metrics dashboard per database. The infrastructure an AI product needs in production: included, not sold back to you as add-ons.
PostgreSQL high availability →# PostgreSQL vs dedicated vector databases
Where keeping vectors in Postgres wins, and where a specialized store still fits.
| PostgreSQL (Rivestack) | Pinecone | Weaviate | Vector add-on | |
|---|---|---|---|---|
| Data model | Vectors + relational rows in one DB | Vectors only | Vectors + limited metadata | Vectors bolted onto shared Postgres |
| Filters & joins | Native SQL (WHERE, JOIN, RLS) | Metadata filters only | GraphQL filters | SQL, but on shared storage |
| Sync overhead | None, single source of truth | Dual-write to keep in sync | Dual-write to keep in sync | None |
| Storage | Dedicated local NVMe | Managed cloud | Managed cloud | Shared cloud block storage |
| Pricing model | Fixed per node, from $29/mo | Usage-metered | Usage-metered | Plan + compute add-ons |
| Best fit | RAG, search & recs with relational context | Pure vector search at huge scale | Vector-native apps | Prototypes outgrowing the free tier |
# from zero to RAG in three steps
Create a database in 30 seconds
Pick a region (EU, US-East, or Singapore) and a node size. pgvector is already enabled, so CREATE EXTENSION vector is a no-op. PostgreSQL 18 with the supported pgvector 0.8.x line ships pre-tuned.
Store embeddings next to your data
Add a vector column to the table that already holds the content. Insert embeddings from OpenAI, Cohere, or your own model, with no separate vector store, no ETL pipeline.
Retrieve with SQL for RAG
Build an HNSW index, then query nearest neighbours with ORDER BY embedding <=> $1, combined with the same WHERE clauses and joins your app already uses. Your existing client library, your existing SQL.
# pricing: fixed, from free to scale
One price per node. No per-query or per-vector billing.
// Prices shown are EU Central, our lowest region. US-East and Singapore are higher. Full pricing.
For prototyping AI features. Shared PostgreSQL with pgvector enabled.
- Shared CPU · 2 GB storage
- pgvector enabled
- ~100K vectors (1536d)
- SSL encrypted
Your own single-tenant VM for small production AI apps. Never deleted.
- 1 vCPU · 2 GB RAM
- 30 GB NVMe storage
- ~300K vectors (1536d)
- Daily backups + 7d PITR
- Never deleted
Production dedicated PostgreSQL with HA-ready architecture.
- 2 vCPU · 4 GB RAM per node
- 55 GB NVMe storage
- HA-ready (Patroni failover)
- Daily backups + 14d PITR
- Monitoring dashboard
More compute and storage for larger embedding sets.
- 4 vCPU · 8 GB RAM per node
- 135 GB NVMe storage
- ~600K vectors (1536d)
- Priority support
High-performance PostgreSQL for demanding AI workloads.
- 8 vCPU · 16 GB RAM per node
- 295 GB NVMe storage
- ~1M vectors (1536d)
- Custom PostgreSQL config
# PostgreSQL for AI FAQ
What teams ask before building AI features on Postgres.
Yes. With the pgvector extension, PostgreSQL stores and searches high-dimensional embeddings using HNSW and IVFFlat indexes, the core of retrieval-augmented generation (RAG), semantic search, and recommendation systems. Because the vectors live next to your relational data, you filter, join, and scope by tenant in standard SQL without running a separate vector database.
For most teams PostgreSQL is the simpler and cheaper choice. RAG retrieval is nearest-neighbour search with filters, which pgvector handles well into the tens of millions of vectors. A dedicated vector database earns its keep at very large scale (hundreds of millions to billions of vectors) or when the workload is pure vector search with no relational context. If your AI feature also needs users, documents, permissions, or metadata, keeping it all in Postgres removes an entire system from your stack.
It depends on how much of the HNSW index fits in RAM. The practical limits are memory for the index, storage IOPS under random reads, and your latency target. Our measured in-RAM fast-search ladder for 1536-dimension vectors: a 4 GB node serves ~300K (we measured 250k at recall@10 0.90 / p50 2.6ms at 4 clients), an 8 GB node ~600K, and a 16 GB node ~1M, and that Scale node builds and serves a full 1M × 1536 index hot at ~3,600 QPS with p50 ~2.3ms (recall@10 0.75, ef_search=80, 16 clients). Larger sets still store fine on the NVMe disk, but once the index spills out of RAM search goes disk-bound and latency climbs, and HNSW index builds get memory-constrained (1M will not build below 16 GB), so benchmark your own dataset before committing.
Any of them. pgvector stores a plain array of floats, so embeddings from OpenAI, Cohere, Voyage, Google, or your own open-source model all work. You just match the vector column dimension to the model output (for example vector(1536) for OpenAI text-embedding-3-small). You can keep multiple embedding columns in one table if you run more than one model.
You do not have to. That is the main advantage of PostgreSQL for AI: the embedding is a column on the same row as the content, written in the same transaction. There is no second datastore to dual-write, no eventual-consistency window, and no reconciliation job. When you delete or update a record, its vector goes with it.
Yes, and more cleanly than vector-only databases. Because filtering is just a SQL WHERE clause, you combine vector similarity with B-tree indexes on the columns you filter on (tenant_id, language, document type, recency) in one query plan. This avoids the "filter then search" vs "search then filter" trade-offs that pure vector stores expose.
HNSW graph traversal is dominated by random reads once the index no longer fits in RAM. Local NVMe delivers far lower random-read latency than general-purpose cloud block storage, which is exactly what tail latency on vector search depends on. On a Starter node (2 vCPU / 4 GB) we measure ~1,185 QPS at recall@10 0.93 (ef_search=80) with p50 3.2ms at 4 clients on a 250k × 1536 HNSW path; on a Scale node the same path reaches ~4,465 QPS at 16 clients, and Scale also builds and serves a full 1M × 1536 index hot at ~3,600 QPS / p50 ~4.2ms: high throughput and low p50 at once, with every figure carrying its recall and client count. The full methodology is in the NVMe vs cloud SSD benchmark.
Yes. Supabase and Neon are standard PostgreSQL with pgvector, so migration is pg_dump / pg_restore for smaller databases or logical replication for always-on workloads, typically 30 to 60 minutes with no application changes. Pinecone is not Postgres, so you re-insert your embeddings into a vector column once; we help map your metadata filters back to SQL columns before you start.
Yes. Both frameworks ship first-class PGVector vector stores. Point them at your Rivestack connection string and they handle inserts and similarity queries for you. Because it is plain PostgreSQL underneath, you can also drop to raw SQL whenever you need joins or filters the framework abstraction does not expose.
A dedicated Rivestack VM with pgvector, NVMe, and daily backups starts at $29/month (Solo), flat, not metered by query volume. The free tier is enough to prototype RAG and semantic search at no cost. There is no per-query or per-vector billing, so cost stays predictable as your AI feature scales.
# PostgreSQL + AI guides
Deeper reads on building AI features on Postgres.
Why managed PostgreSQL is the best choice for AI workloads
The case for one transactional database over a separate vector store, and what to size for in production.
Building RAG with pgvector and OpenAI
A practical walkthrough: embeddings, an HNSW index, and retrieval with metadata filters in plain SQL.
pgvector vs Pinecone
When PostgreSQL is the right home for your vectors, and when a dedicated vector database still wins.
// Looking for hosted vector search specifically? See managed pgvector, managed PostgreSQL, and the pgvector guide.