pgsentinel
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgsentinel | 1.5.1 | STAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 6410 | pgsentinel | No | Yes | Yes | Yes | No | Yes | - |
| Related | pg_datasentinel pg_profile pg_stat_monitor pg_wait_sampling pg_stat_ch pgmonitor system_stats pgnodemx powa pg_stat_statements |
|---|
Requires preload alongside pg_stat_statements.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.5.1 | 1817161514 | pgsentinel | - |
| RPM | PGDG | 1.5.1 | 1817161514 | pgsentinel_$v | - |
| DEB | PGDG | 1.5.1 | 1817161514 | postgresql-$v-pgsentinel | - |
Build
You can build the RPM / DEB packages for pgsentinel using pig build:
Install
You can install pgsentinel directly. First, make sure the PGDG repository is added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Create Extension:
Usage
Sources:
pgsentinel records active session history by sampling pg_stat_activity at regular intervals and linking activity with pg_stat_statements query statistics. It keeps recent samples in shared-memory ring buffers managed by a background worker.
Restart PostgreSQL, then enable both extensions in the database used by the worker:
Active Session History
Key columns beyond pg_stat_activity:
| Column | Description |
|---|---|
ash_time | Sampling timestamp |
top_level_query | Top-level statement (for PL/pgSQL) |
query | Statement with actual parameter values |
cmdtype | Statement type: SELECT, UPDATE, INSERT, DELETE, UTILITY, UNKNOWN, NOTHING |
queryid | Links to pg_stat_statements |
blockers | Number of blocking processes |
blockerpid | PID of a blocking process |
blocker_state | State of the blocker |
Query Statistics History
When enabled, pgsentinel also samples pg_stat_statements concurrently:
Example: Wait Analysis
Configuration
| Parameter | Default | Description |
|---|---|---|
pgsentinel_ash.sampling_period | 1 | Sampling period in seconds |
pgsentinel_ash.max_entries | 1000 | Ring buffer size for ASH |
pgsentinel.db_name | postgres | Database for worker connection |
pgsentinel_ash.track_idle_trans | false | Track idle-in-transaction sessions |
pgsentinel_pgssh.max_entries | 1000 | Ring buffer for pg_stat_statements history |
pgsentinel_pgssh.enable | false | Enable pg_stat_statements history |
Version and Privilege Changes
Version 1.5.0 separates queryid from nested_queryid: on PostgreSQL 16 and later the former comes from the activity query identifier, while the latter identifies the inner parsed statement; they match on older versions. The upgrade recreates the history view, so inspect dependent views and grants first.
Version 1.5.1 revokes PUBLIC execution of get_parsedinfo(int) because it can expose other backends’ query text and literals. Apply the SQL upgrade after installing the new files, and grant access only to roles that need it:
History remains in finite shared-memory ring buffers; export it for long-term retention. Sampled query text can contain sensitive values, so review access to history views as well. Upstream CI covers PostgreSQL 10–19.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)