Engineering4 min read

Managed Postgres vs self-hosting: an honest comparison

Both ways of running Postgres are legitimate; they trade different things away. Backups, upgrades, connection pooling, cost and operational risk — plus how to run Postgres on TheCodexApps either way.

TheCodexApps Team

Every team that needs Postgres eventually faces the same decision: pay a managed-database provider to run it, or run it yourself on a server you control. Both are legitimate. The honest version of this comparison is not "managed is safer, self-hosted is cheaper" — it is about which specific chores you want on your plate. Here is how the trade-offs actually break down.

What "managed" really buys you

A managed Postgres (from any provider) is not a different database — it is the same Postgres with three services wrapped around it:

  1. Automated backups with point-in-time recovery, tested by the provider.
  2. Upgrades handled by someone else, usually with a rolling restart.
  3. An operations team that notices problems before you do.

What you give up is root: no superuser, no arbitrary extensions, no file-system access, and often no way to tune beyond the knobs the provider exposes. You also accept their maintenance windows and their pricing curve, which tends to be steep per gigabyte.

What self-hosting gives you

Running Postgres on your own server means:

  • full superuser access and any extension you can install,
  • direct file access for pg_dump, pg_basebackup or custom tooling,
  • a flat, predictable cost — the database shares your resource pool,
  • no vendor lock-in: the data directory is yours.

What you accept in return is the operational checklist: backups you must configure and test, upgrades you must schedule, monitoring you must wire up, and 3 a.m. pages that come to you.

Backups: the part everyone underestimates

A backup you have never restored is a hope, not a backup. Managed providers handle this well — it is a large part of what you pay for. Self-hosting is fine too, but only if you do the work:

  • run pg_dump on a schedule and ship the dumps off the server,
  • test a restore into a scratch database at least once,
  • keep WAL archiving (or base backups) if you need point-in-time recovery.

On TheCodexApps, self-hosted databases get scheduled backups stored off-server, which covers the first two points for you — but testing a restore is still on you, and it should be.

Upgrades

Postgres releases a new major version yearly, and old versions stop receiving security fixes after five years. Managed providers run the upgrade for you, often invisibly. Self-hosting means reading the release notes, running pg_upgrade (or dump-and-restore), and rehearsing it on a copy first. Neither path is hard; one of them appears on your calendar.

Connection pooling

Serverless platforms and busy app servers open far more connections than a small Postgres wants to serve — every connection is a process with its own memory budget. Managed providers sell pooling as an add-on (or bundle PgBouncer). Self-hosting means running PgBouncer yourself, which is one extra container and a config file:

[databases]
mydb = host=127.0.0.1 port=5432 dbname=mydb

[pgbouncer]
pool_mode = transaction
max_client_conn = 200
default_pool_size = 20

If your app framework pools connections sensibly (a modest max_connections per instance), you may not need PgBouncer at all until you run several app replicas.

Cost

Managed Postgres pricing scales with RAM and storage and is rarely cheap; a database large enough for a serious workload can cost more than the app servers around it. Self-hosting folds the database into your existing resource pool: a 2 GB package runs both a small app and its Postgres, which is often the entire database budget. The gap narrows as data grows — at some point the operational risk of a big self-hosted database justifies the managed bill. That point is further away than most people assume.

Running Postgres on TheCodexApps

Both styles are supported:

  • One-click: deploy Postgres from the Apps catalog, pick a name, and get a running instance with persistent storage, scheduled backups and a connection string in the panel. Add a database and user, and point your app at it.
  • Your own: deploy from a Docker image or your compose file if you want specific extensions or a particular configuration; the same persistence and backup guarantees apply.

Either way, put the database in the same package as the app when it is small — the latency between services on the same host is effectively zero, which is a real performance win no managed provider can match at any price.

Which should you choose?

Use a managed Postgres when your team is small, the database is the product, and nobody wants to think about it — the premium buys sleep. Self-host when you want full control, predictable cost, and low latency between app and database, and accept a short operational checklist in exchange. The wrong answer is the middle ground: a self-hosted database nobody maintains. Pick a side deliberately, and either one works.

Try it yourself, free.

Create an account, pick a package and get a live URL in minutes.