PostgreSQL ships predefined roles so you can grant narrow powers instead of making someone superuser. Use pg_read_all_data for read-only reporting and pg_monitor for monitoring. Treat pg_read_server_files, pg_write_server_files and pg_execute_server_program as superuser equivalent, because the manual says they could be used to gain superuser level access.
Data access roles
pg_read_all_datareads all tables, views and sequences, as if holdingSELECTon them andUSAGEon all schemas.pg_write_all_datawrites all of them, as if holdingINSERT,UPDATEandDELETE.
Neither bypasses row level security, which is a useful property when you also use policies. See row level security basics.
Monitoring roles
pg_monitorreads and executes monitoring views and functions. It is a member ofpg_read_all_settings,pg_read_all_statsandpg_stat_scan_tables.pg_read_all_settingsreads all configuration variables, including those normally visible only to superusers.pg_read_all_statsreads thepg_stat_*views.
A monitoring agent needs pg_monitor, not a superuser login. That one change removes a surprising amount of risk.
Maintenance and signaling
pg_maintainrunsVACUUM,ANALYZE,CLUSTER,REINDEXand similar on all relations.pg_signal_backendcancels queries or terminates sessions of other backends, but not those owned by a superuser.pg_checkpointrunsCHECKPOINT.
The three to treat as superuser
pg_read_server_files, pg_write_server_files and pg_execute_server_program let a role read or write files, or run programs, as the database's operating system user, using COPY and related functions. The manual warns they bypass database level permission checks for direct file access and could be used to gain superuser level access. Do not hand them to application accounts.
How to apply this
- List your non-human logins: monitoring, backups, reporting, migrations.
- For each, write down what it really does.
- Grant the matching predefined role, or specific table privileges, instead of superuser.
- Keep application roles away from the server file and program roles entirely.
- Re-review after upgrades. The manual advises watching release notes because role permissions may change.
Grants on future tables need their own handling, covered in ALTER DEFAULT PRIVILEGES.
Quick check
Can pg_read_all_data replace superuser for a reporting tool?
For reading table data, yes. It grants read access across tables, views and sequences without superuser, and it does not bypass row level security.
Sources
Last reviewed: 19 October 2026.