Code Reference

Getting Started with Postgres Ops

Postgres · Reference cheat sheet

Getting Started with Postgres Ops

Postgres · Reference cheat sheet


📋 Overview

PostgreSQL is a relational database used as a system of record. This folder focuses on operations and administration: connections, roles, indexes, vacuum, explain, backups, pooling, and JSONB — not basic SELECT tutorials.

🔧 Core concepts

IdeaMeaning
ClusterA Postgres data directory + running server
DatabaseNamed DB inside a cluster
RoleUser/group identity for authz
WALWrite-ahead log for durability/replication
ExtensionPackaged server plugin (CREATE EXTENSION)
ToolPurpose
psqlInteractive SQL + meta-commands
pg_dump / pg_restoreLogical backup/restore
pg_basebackupPhysical base backup
Connection poolerPgBouncer / cloud poolers

💡 Examples

Run Postgres (Docker):

docker run --rm -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:16

Connect:

psql "postgres://postgres:postgres@127.0.0.1:5432/postgres"

Version + basics:

SELECT version();
SELECT current_database(), current_user;

⚠️ Pitfalls

  • Exposing 5432 publicly without TLS/auth hardening is dangerous.
  • Superuser for app runtimes violates least privilege.
  • Skipping backups until first incident is not a strategy.

On this page