Skip to content
pg_wait_sampling

pg_wait_sampling

pg_wait_sampling : sampling based statistics of wait events

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
6280
pg_wait_sampling
pg_wait_sampling
1.1.9
STAT
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--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

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
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 / PGPG18PG17PG16PG15PG14
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
u26.x86_64
PGDG 1.1.9
PGDG 1.1.9
PGDG 1.1.9
PGDG 1.1.9
PGDG 1.1.9
u26.aarch64
PGDG 1.1.9
PGDG 1.1.9
PGDG 1.1.9
PGDG 1.1.9
PGDG 1.1.9
PackageVersionOSORGSIZEFile URL
pg_wait_sampling_181.1.9el8.x86_64pgdg24.4 KiBpg_wait_sampling_18-1.1.9-1PGDG.rhel8.x86_64.rpm
pg_wait_sampling_181.1.9el8.aarch64pgdg24.1 KiBpg_wait_sampling_18-1.1.9-1PGDG.rhel8.aarch64.rpm
pg_wait_sampling_181.1.9el9.x86_64pgdg24.0 KiBpg_wait_sampling_18-1.1.9-1PGDG.rhel9.x86_64.rpm
pg_wait_sampling_181.1.9el9.aarch64pgdg23.9 KiBpg_wait_sampling_18-1.1.9-1PGDG.rhel9.aarch64.rpm
pg_wait_sampling_181.1.9el10.x86_64pgdg24.5 KiBpg_wait_sampling_18-1.1.9-1PGDG.rhel10.x86_64.rpm
pg_wait_sampling_181.1.9el10.aarch64pgdg24.7 KiBpg_wait_sampling_18-1.1.9-1PGDG.rhel10.aarch64.rpm
postgresql-18-pg-wait-sampling1.1.9d12.x86_64pgdg38.2 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg12+1_amd64.deb
postgresql-18-pg-wait-sampling1.1.9d12.aarch64pgdg38.0 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg12+1_arm64.deb
postgresql-18-pg-wait-sampling1.1.9d13.x86_64pgdg38.4 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg13+1_amd64.deb
postgresql-18-pg-wait-sampling1.1.9d13.aarch64pgdg38.0 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg13+1_arm64.deb
postgresql-18-pg-wait-sampling1.1.9u22.x86_64pgdg38.8 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg22.04+1_amd64.deb
postgresql-18-pg-wait-sampling1.1.9u22.aarch64pgdg38.5 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg22.04+1_arm64.deb
postgresql-18-pg-wait-sampling1.1.9u24.x86_64pgdg38.4 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg24.04+1_amd64.deb
postgresql-18-pg-wait-sampling1.1.9u24.aarch64pgdg38.0 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg24.04+1_arm64.deb
postgresql-18-pg-wait-sampling1.1.9u26.x86_64pgdg38.2 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg26.04+1_amd64.deb
postgresql-18-pg-wait-sampling1.1.9u26.aarch64pgdg37.3 KiBpostgresql-18-pg-wait-sampling_1.1.9-2.pgdg26.04+1_arm64.deb

Source

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg repo and update cache

Install 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 14

Config 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: sampling based statistics of wait events

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;
ColumnTypeDescription
pidint4Process ID
event_typetextWait event type
eventtextWait event name
queryidint8Query ID

Wait event history (ring buffer of recent samples):

SELECT * FROM pg_wait_sampling_history;
ColumnTypeDescription
pidint4Process ID
tstimestamptzSample timestamp
event_typetextWait event type
eventtextWait event name
queryidint8Query ID

Wait event profile (cumulative counts):

SELECT * FROM pg_wait_sampling_profile;
ColumnTypeDescription
pidint4Process ID
event_typetextWait event type
eventtextWait event name
queryidint8Query ID
counttextCount 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

ParameterDefaultDescription
pg_wait_sampling.history_size5000Ring buffer size
pg_wait_sampling.history_period10History sampling period (ms)
pg_wait_sampling.profile_period10Profile sampling period (ms)
pg_wait_sampling.profile_pidtrueCollect profile per-process
pg_wait_sampling.profile_queriestopPer-query profile: none, top, all
pg_wait_sampling.sample_cputrueSample 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