Skip to content

PostgreSQL checklist

Copy this list into a pull request, design review or project kickoff and tick what applies. Rules are grouped by level and sorted by score (criteria). Each links to the file that explains it and cites its sources. Automatable names tools that can check the rule in CI (see the file's "How to enforce" section).

Also apply the general checklist.

This file is generated by python3 scripts/rank.py fix from the guidelines. Don't edit it by hand.

  • PG-11 (9) Test restores regularly, and check that the restored database works and contains the correct data. (specific/postgres) Automatable: pg_verifybackup, pgBackRest check.
  • PG-16 (9) Run a supported major version, apply each minor release soon after it ships, and upgrade to a newer major version before the current one reaches end of life. (specific/postgres)
  • PG-1 (8) Declare integrity rules as constraints in the database: a primary key on every table, NOT NULL on most columns, and foreign key, unique and check constraints where the data needs them. (specific/postgres)
  • PG-6 (8) Create and drop indexes on tables in use with CREATE INDEX CONCURRENTLY and DROP INDEX CONCURRENTLY. (specific/postgres) Automatable: Squawk.
  • PG-12 (8) Back up production databases with continuous archiving, base backups plus archived WAL, so that you can restore to any point in time, not only to the last dump. (specific/postgres) Automatable: pgBackRest check.
  • PG-13 (8) Connect the application as a role that isn't a superuser and doesn't own the tables, and grant it only the privileges it needs; run migrations as a separate owner role. (specific/postgres)
  • PG-2 (7) Store points in time as timestamptz, not timestamp. (specific/postgres) Automatable: Squawk.
  • PG-5 (7) Add indexes for the queries the application actually runs: find the costly ones with pg_stat_statements, check their plans with EXPLAIN ANALYZE on realistic data, and drop indexes that are never used. (specific/postgres)
  • PG-7 (7) Set a short lock_timeout at the start of each migration, and retry the migration when it times out. (specific/postgres) Automatable: Squawk.
  • PG-8 (7) Add foreign key and check constraints to existing tables as NOT VALID, then run VALIDATE CONSTRAINT in a separate transaction. (specific/postgres) Automatable: Squawk.
  • PG-9 (7) Put a connection pooler such as PgBouncer between the database and large numbers of clients, such as many app instances or serverless functions, instead of raising max_connections. (specific/postgres)
  • PG-10 (7) Keep transactions short, set idle_in_transaction_session_timeout to end abandoned ones, and leave autovacuum on. (specific/postgres)
  • PG-14 (7) Use scram-sha-256 password authentication over TLS, and have clients verify the server with sslmode=verify-full. (specific/postgres)
  • PG-3 (6) Generate keys with identity columns, such as id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY, instead of serial. (specific/postgres) Automatable: Squawk.
  • PG-4 (6) Use text for strings, rather than char(n) or a varchar(n) with an arbitrary limit. (specific/postgres) Automatable: Squawk.

Conditional (1–5)

  • PG-15 (5) When tenants share tables, isolate their rows with row security policies, and make sure the application role isn't the table owner or use FORCE ROW LEVEL SECURITY. (specific/postgres)