pg_wait_sampling
sampling based statistics of wait events
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_wait_sampling | 1.1.9 | STAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 6280 | pg_wait_sampling | No | Yes | Yes | Yes | No | Yes | - |
| Related | powa pg_stat_statements pg_background pg_stat_kcache system_stats pgnodemx pg_profile pgsentinel |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.1.9 | 1817161514 | pg_wait_sampling | - |
| RPM | PGDG | 1.1.9 | 1817161514 | pg_wait_sampling_$v | - |
| DEB | PGDG | 1.1.9 | 1817161514 | postgresql-$v-pg-wait-sampling | - |
Install
You can install pg_wait_sampling directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_wait_sampling; # Install for current active PG version
pig ext install -y pg_wait_sampling -v 18 # PG 18
pig ext install -y pg_wait_sampling -v 17 # PG 17
pig ext install -y pg_wait_sampling -v 16 # PG 16
pig ext install -y pg_wait_sampling -v 15 # PG 15
pig ext install -y pg_wait_sampling -v 14 # PG 14
dnf install -y pg_wait_sampling_18 # PG 18
dnf install -y pg_wait_sampling_17 # PG 17
dnf install -y pg_wait_sampling_16 # PG 16
dnf install -y pg_wait_sampling_15 # PG 15
dnf install -y pg_wait_sampling_14 # PG 14
apt install -y postgresql-18-pg-wait-sampling # PG 18
apt install -y postgresql-17-pg-wait-sampling # PG 17
apt install -y postgresql-16-pg-wait-sampling # PG 16
apt install -y postgresql-15-pg-wait-sampling # PG 15
apt install -y postgresql-14-pg-wait-sampling # PG 14
Preload:
shared_preload_libraries = 'pg_wait_sampling';
Create Extension:
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;
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.