pg_governor
pg_workload · Role-group admission control, connection limits and workload statistics.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102348 | pg_governor | pg_workload | 0.1 | ADMIN | Apache-2.0 | C |
PostgreSQL · 15, 16, 17
Usage
Sources:
pg_governor 0.1 limits concurrent top-level queries and connections for directly assigned role groups. It supports PostgreSQL 15–17. Admission priority controls queue order, not CPU or I/O allocation.
Configure a workload group
Preload the library and restart. Create the extension in the database selected by pg_governor.database; the example assumes role alice already exists.
Limits and administration
The example allows two active queries, a 5000 ms wait, 65536 KB of work_mem, 20 connections and priority 3. Higher priority wins; equal priority is FIFO. Zero active/connection limits mean unlimited; zero wait means no timeout. pg_governor.max_active_total and pg_governor.max_connections_total add instance ceilings for managed roles.
governor.alter_group, governor.assign_role, governor.unassign_role, governor.drop_group and governor.reload change configuration. Administrative functions are revoked from PUBLIC; statistics are publicly readable. Cumulative counters are periodically saved by the worker; a crash can lose the most recent interval.
Operational boundaries
governor.reload() changes shared state nontransactionally. After rolling back a configuration change, call it again to align shared memory with the tables. Only directly assigned roles are controlled; role membership does not inherit a group. Nested queries and queries while a cursor is open are not independently counted. The shared queue holds at most 1024 waiting queries. Drop groups before removing the extension: DROP EXTENSION does not clear shared state. This is not a CPU, memory or I/O isolation mechanism.