pg_wait_sampling
pg_wait_sampling
pg_wait_sampling : sampling based statistics of wait events
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 6280 | pg_wait_sampling | pg_wait_sampling | 1.1.9 | STAT | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd-r | No | Yes | Yes | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | powa pg_stat_statements pg_background pg_stat_kcache system_stats pgnodemx pg_profile pgsentinel |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG | 1.1.9 | 18 17 16 15 14 | pg_wait_sampling | - |
| RPM | PGDG | 1.1.9 | 18 17 16 15 14 | pg_wait_sampling_$v | - |
| DEB | PGDG | 1.1.9 | 18 17 16 15 14 | postgresql-$v-pg-wait-sampling | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
el8.aarch64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
el9.x86_64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
el9.aarch64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
el10.x86_64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
el10.aarch64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
d12.x86_64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
d12.aarch64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
d13.x86_64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
d13.aarch64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
u22.x86_64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
u22.aarch64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
u24.x86_64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
u24.aarch64 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 | PGDG 1.1.9 |
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install pg_wait_sampling; # install via package name, for the active PG version
pig install pg_wait_sampling -v 18; # install for PG 18
pig install pg_wait_sampling -v 17; # install for PG 17
pig install pg_wait_sampling -v 16; # install for PG 16
pig install pg_wait_sampling -v 15; # install for PG 15
pig install pg_wait_sampling -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pg_wait_sampling';Create this extension with:
CREATE EXTENSION pg_wait_sampling;Usage
pg_wait_sampling collects wait event statistics by periodically sampling what each backend is waiting on. It provides both a recent history ring buffer and a cumulative profile.
Views
Current wait events:
SELECT * FROM pg_wait_sampling_current;| Column | Type | Description |
|---|---|---|
pid | int4 | Process ID |
event_type | text | Wait event type |
event | text | Wait event name |
queryid | int8 | Query ID |
Wait event history (ring buffer of recent samples):
SELECT * FROM pg_wait_sampling_history;| Column | Type | Description |
|---|---|---|
pid | int4 | Process ID |
ts | timestamptz | Sample timestamp |
event_type | text | Wait event type |
event | text | Wait event name |
queryid | int8 | Query ID |
Wait event profile (cumulative counts):
SELECT * FROM pg_wait_sampling_profile;| Column | Type | Description |
|---|---|---|
pid | int4 | Process ID |
event_type | text | Wait event type |
event | text | Wait event name |
queryid | int8 | Query ID |
count | text | Count of samples |
Get current wait event for a specific process:
SELECT * FROM pg_wait_sampling_get_current(12345);Reset Profile
SELECT pg_wait_sampling_reset_profile();Configuration
| Parameter | Default | Description |
|---|---|---|
pg_wait_sampling.history_size | 5000 | Ring buffer size |
pg_wait_sampling.history_period | 10 | History sampling period (ms) |
pg_wait_sampling.profile_period | 10 | Profile sampling period (ms) |
pg_wait_sampling.profile_pid | true | Collect profile per-process |
pg_wait_sampling.profile_queries | top | Per-query profile: none, top, all |
pg_wait_sampling.sample_cpu | true | Sample on-CPU backends (event columns NULL) |
Example: Top Wait Events
SELECT event_type, event, count
FROM pg_wait_sampling_profile
ORDER BY count DESC
LIMIT 10;Last updated on