A PostgreSQL checklist for your first production app
Seven things to set up on day one so your Postgres database stays fast, safe and recoverable as your startup grows.
PostgreSQL is forgiving early on, which is exactly why teams skip the basics. Six months later the app is slow, a migration locks a table during peak hours, and nobody is sure the backups work. These are the things we set up on every new project.
1. Backups you have actually restored
Turn on point-in-time recovery with your provider, then restore a backup into a scratch database and check the data. Put the steps in your README. A backup you have never restored is a hope, not a plan.
2. Connection pooling
Serverless functions open many short connections. Use PgBouncer or your provider's pooler so you don't hit the connection limit on a busy day.
3. Migrations in version control
Every schema change should be a reviewed migration file that runs in CI. Never change production tables by hand.
4. Indexes for your real queries
Enable pg_stat_statements and look at the slowest queries every few weeks. Add indexes for the columns you filter and join on, and remove ones nobody uses.
5. Separate roles
Your app should not connect as the superuser. Create a role with only the permissions it needs, and a read-only role for analytics.
6. Timestamps and soft deletes where they matter
Add created_at and updated_at to every table. For important records, consider a deleted_at column so mistakes can be undone.
7. Alerts before users notice
- Disk usage above 80%
- Replication lag, if you use replicas
- Long-running queries and lock waits
- Failed backup jobs
None of this takes long when the project is new. All of it is painful to add after an incident.
