PostgreSQL
The world's most advanced open-source relational database.
PostgreSQL is a battle-tested, fully ACID-compliant SQL database with first-class JSON support, full-text search, geospatial indexes, and an enormous extension ecosystem. Pier deploys the official Docker image with automated backups, point-in-time recovery, and one-click replicas.
Deploy with Pier
- 1 Open the Pier dashboard and click Add service.
- 2 Pick PostgreSQL from the template list.
- 3 Choose the version, set a service name, and Pier provisions the container, storage, and ports automatically.
- 4 Attach a domain if you want HTTPS. Traefik auto-provisions the Let's Encrypt certificate.
What is PostgreSQL?
PostgreSQL (“Postgres”) is an open-source object-relational database that has been in active development for over 30 years. It’s the default choice for new application backends across industries — from one-person startups to Apple, Instagram, Reddit, and most of the European banking sector.
What sets it apart from MySQL and other “easy” databases is the depth of its type system, query planner, and extension model. JSONB lets it act like a document database. PostGIS turns it into a geospatial server. pgvector makes it a vector search engine. TimescaleDB adds time-series. You rarely outgrow Postgres — you grow extensions on top of it.
How Pier deploys it
Pier uses the official postgres Docker image, mounting /var/lib/postgresql
as the data volume. The default version is latest (currently PostgreSQL 18);
versions 18-alpine, 17-alpine, and 16-alpine are also available.
For single-node deployments, Pier provisions a strong password, creates the container, exposes port 5432 internally, and (optionally) publishes via Traefik. For clustered deployments, Pier switches to the bitnami/postgresql image which supports streaming replication out of the box — 1 primary + N read replicas, configurable from 2 to 5 nodes total.
Backups run on schedule (per-database or cluster-wide) using pg_dump custom
format. Backups can be uploaded to any S3-compatible storage configured in
Pier’s S3 Storages settings.
When NOT to use PostgreSQL
For embedded, single-process applications, SQLite is simpler and lighter. For pure key-value workloads with no relations and sub-millisecond latency targets, Redis or Valkey are better fits. For petabyte-scale OLAP with no transactional requirements, ClickHouse wins on raw throughput.
For almost everything else — Postgres.
Key features
Full ACID & MVCC
True serializable isolation, foreign keys, triggers, stored procedures (in plpgsql, Python, JS, Rust). Multi-version concurrency without read locks.
Rich type system
Native JSONB with indexes and operators, arrays, ranges, UUID, geometric types, custom types, enums. JSONB is fast enough that Postgres often replaces document databases.
Streaming replication & WAL
Synchronous or async physical replicas, logical replication for cross-version migrations and CDC, point-in-time recovery via WAL archiving.
Performance at any scale
Cost-based query planner with parallel scans, BRIN indexes for billion-row tables, partitioning by range/list/hash, partial and expression indexes.
Extension ecosystem
PostGIS (geospatial), TimescaleDB (time-series), pgvector (AI embeddings), pg_partman, pg_stat_statements, pg_repack, foreign data wrappers — Postgres is a database you grow into.
Cluster-ready on Pier
1 primary + N read replicas with streaming replication via the bitnami/postgresql image. Pier handles healthchecks and connection routing.
Use cases
SaaS application backend
The default choice for new application backends. Works with Prisma, Sequelize, SQLAlchemy, Hibernate, GORM, ActiveRecord, Diesel — every mainstream ORM.
Multi-tenant data with row-level security
Native row-level security policies enforce tenant isolation at the database, not the application — leak-proof multi-tenancy.
Geospatial workloads (with PostGIS)
Maps, routing, geofencing, fleet tracking — PostGIS adds 1000+ spatial functions, R-tree indexes, projections, and topology.
AI / vector search (with pgvector)
Store and query 1536-dim embeddings with HNSW or IVFFlat indexes. Skip the dedicated vector DB if Postgres already holds your other data.
Analytics & BI source
Connect Metabase, Superset, Grafana, Tableau directly. Materialized views and partitioning handle hundreds of millions of rows comfortably.
Code examples
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email TEXT UNIQUE NOT NULL,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
profile JSONB NOT NULL DEFAULT '{}'::jsonb
);
CREATE INDEX users_created_idx ON users (created_at DESC);
CREATE INDEX users_profile_gin ON users USING gin (profile); SELECT id, email
FROM users
WHERE profile @> '{"plan": "pro"}'
AND (profile->>'signups')::int > 5
ORDER BY created_at DESC
LIMIT 50; ALTER TABLE invoices ENABLE ROW LEVEL SECURITY;
CREATE POLICY tenant_isolation
ON invoices
FOR ALL
USING (tenant_id = current_setting('app.tenant_id')::uuid);
-- Per-request:
SET app.tenant_id = '550e8400-e29b-41d4-a716-446655440000'; CREATE TABLE events (
id BIGSERIAL,
occurred_at TIMESTAMPTZ NOT NULL,
payload JSONB
) PARTITION BY RANGE (occurred_at);
CREATE TABLE events_2026_05 PARTITION OF events
FOR VALUES FROM ('2026-05-01') TO ('2026-06-01'); How it compares
| vs MySQL / MariaDB | MySQL is simpler and still fast for the basics, but Postgres wins on JSON, full-text search, geospatial, partial indexes, CTEs, and SQL standard compliance. Pick Postgres for anything non-trivial. |
| vs MongoDB | Postgres's JSONB matches Mongo's flexibility while keeping joins, transactions, and SQL. Most teams that picked Mongo for "schema flexibility" eventually migrate back. |
| vs SQLite | SQLite is unbeatable for embedded use and single-writer apps. Postgres takes over when you need concurrent writes, network access, or replication. |
| vs Managed Postgres (RDS, Cloud SQL, Supabase) | Self-hosting on Pier gives you the same Postgres at a fraction of the cost — typical savings 10–30× for small/medium workloads. You give up the SaaS UI but gain control and portability. |
Frequently asked questions
Which PostgreSQL version does Pier deploy by default?
Are backups automatic?
Can I run replicas?
How do I add extensions like PostGIS or pgvector?
Does it support row-level security?
What ports are exposed?
Can my existing ORM (Prisma, Sequelize, Diesel) connect?
Related services
Deploy on your VPS
PostgreSQL is a battle-tested, fully ACID-compliant SQL database with first-class JSON support, full-text search, geospatial indexes, and an enormous extension ecosystem. Pier deploys the official Docker image with automated backups, point-in-time recovery, and one-click replicas.
Deploy this service →