Use it to operate or troubleshoot PostgreSQL servers.
PostgreSQL
PostgreSQL is an open-source relational database with MVCC, WAL, rich types and extensions, configured in postgresql.conf and pg_hba.conf and managed with psql.
1. pg_lsclusters / systemctl status postgresql; server log.
2. Connections: SELECT count(*) FROM pg_stat_activity; vs max_connections.
3. Autovacuum and bloat.
4. Disk for data and WAL.
5. Replication: pg_stat_replication.
client → pg_hba auth → backend process → shared buffers/WAL → data files
Frequent failures include pg_hba/authentication mismatches, WAL retention filling disks, long transactions preventing vacuum cleanup, autovacuum lag, replication slots retaining WAL and assuming pg_dump is equivalent to a physical/PITR-capable backup. Preserve the first divergent observation and repeat the same bounded verification after remediation.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Databases owns PostgreSQL engine and WAL/VACUUM behavior. Host, storage and general network issues remain in their owning Domains.
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Verification workflow Verify boundary
Confirm PostgreSQL version/cluster, database/role context and effective configuration. Check connection rules, WAL generation/retention, autovacuum health and table bloat indicators. Validate backup by restore, and validate replicas by receive/replay positions plus queryable service state.
Step 2 Failure signatures and limits Narrow the fault
Frequent failures include pg_hba/authentication mismatches, WAL retention filling disks, long transactions preventing vacuum cleanup, autovacuum lag, replication slots retaining WAL and assuming pg_dump is equivalent to a physical/PITR-capable backup.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Subtopics
Go one level deeper into this subject.
pg_hba.conf decides which clients may connect to which databases as which users, and which authentication method they must use.
Subtopic PostgreSQL Roles and PrivilegesPostgreSQL uses roles for both users and groups; privileges are granted on databases, schemas, tables and sequences.
Subtopic WAL and CheckpointsPostgreSQL writes every change to the write-ahead log (WAL) first; checkpoints flush changed data pages to disk so old WAL can be recycled.
Watch connections (use a pooler), autovacuum, WAL/disk, and pg_hba.conf for access. pg_stat_statements shows the heaviest queries.
SELECT * FROM pg_stat_activity;— sessionspsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
ReferenceWhat it is1 section · depth on demand
Operating model
PostgreSQL covers the PostgreSQL cluster/server model, roles/databases, WAL durability, vacuuming, configuration/logging, backup choices and streaming replication. PostgreSQL MVCC leaves dead tuples that require vacuum management; WAL is central to crash recovery, replication and point-in-time recovery.
ReferenceHow it works1 section · depth on demand
In depth
PostgreSQL is an advanced open-source relational database known for standards compliance, reliability, rich data types (JSONB, arrays, inet, ranges) and extensions (PostGIS, TimescaleDB, pgvector). It is the default choice for many new applications, including NetBox.
Operational essentials:
| Area | Practice |
|---|---|
| Configuration | shared_buffers ~25% RAM, effective_cache_size, work_mem carefully; connection pooling (PgBouncer) for many clients |
| Vacuum | Autovacuum tuned and monitored; avoid long-running transactions |
| Backup | pg_dump (logical), pg_basebackup + WAL archiving or pgBackRest/Barman for PITR |
| Replication | Streaming replication, logical replication; Patroni for automated failover |
| Security | pg_hba.conf restrictions, SCRAM-SHA-256 passwords, TLS, least-privilege roles |
| Monitoring | pg_stat_activity, pg_stat_statements, replication lag |
SELECT pid, state, wait_event_type, now()-xact_start AS xact_age, left(query,60)
FROM pg_stat_activity WHERE state <> 'idle' ORDER BY xact_age DESC NULLS LAST;
Major version upgrades need pg_upgrade or logical replication — plan them, since each major version is supported for five years.
ReferenceImportant terms & boundaries1 section · depth on demand
Scope map
- Server/cluster architecture
- Roles and databases
- WAL
- VACUUM / autovacuum
- Configuration and logs
- pg_dump/base backup boundaries
- Streaming replication
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Configuration & expected output
Concrete examples are shown only when the stored reference contains an actual configuration or output shape for this Topic.
Configuration example
Assumptions: Debian/Ubuntu paths; application subnet 10.0.20.0/24.
# postgresql.conf
listen_addresses = '10.0.10.22'
password_encryption = scram-sha-256
# pg_hba.conf
# TYPE DATABASE USER ADDRESS METHOD
hostssl app app_rw 10.0.20.0/24 scram-sha-256Expected output
psql -c "SELECT pg_reload_conf();" && psql -c "SELECT type, database, user_name, address, auth_method FROM pg_hba_file_rules WHERE error IS NULL;"Expected state: The reloaded pg_hba rules contain the intended rule with no parse errors.
type | database | user_name | address | auth_method
---------+----------+------------+------------+---------------
local | {all} | {postgres} | | peer
hostssl | {app} | {app_rw} | 10.0.20.0 | scram-sha-256Rules are matched top to bottom; the first match wins. listen_addresses needs a restart, pg_hba.conf only a reload. Illustrative authored output: field layout matches the tool, values will differ in your environment.Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Documentation verification: confirms the upstream model used by the Topic. It does not assert local production behavior.
Basis: https://www.postgresql.org/docs/current/ · confidence 92%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
PostgreSQL verification boundary matrix
A compact lookup separating intent, owning component state, effective state and consumer-visible outcome for PostgreSQL.
| Boundary | Inspect | Healthy interpretation | Do not infer |
|---|---|---|---|
| Intent | Server/cluster architecture | Intended object/scope is explicit and versioned where relevant | Intent is already effective |
| Owning runtime/control plane | Roles and databases / WAL | Owner accepts and reports the expected object state | Downstream dependencies are healthy |
| Effective state | VACUUM / autovacuum | Independent read-back matches the intended state | Every client sees the same result |
| Consumer outcome | Configuration and logs | The original bounded check succeeds in the same time window | Production correctness outside this scope |
Deep reference
Design & tradeoffs
Scope
Host, storage and general network issues remain in their owning Domains.