← Browse the extensions catalog

pg-wait-sampling

Source README ↗

pg-wait-sampling

pg_wait_sampling samples PostgreSQL wait events and exposes current, historical, and aggregated profile views in SQL.

Follow the quick start to set up extension-update email alerts first, then use the CronJob to install and refresh the catalog. These examples inherit image references and runtime settings from the catalog. The Cluster YAML is an excerpt: replace imageCatalogRef: ... with your catalog reference and keep your existing instance and storage settings.

Usage

1. Add the pg-wait-sampling extension image to your Cluster

Add the extension image and preload its worker in a complete Cluster definition:

apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
  name: cluster-pg-wait-sampling
spec:
  imageCatalogRef: ...
  postgresql:
    shared_preload_libraries:
    - pg_wait_sampling
    extensions:
    - name: pg-wait-sampling

2. Enable the extension in a database

Once the extension's files are available in the cluster, you can install it in a database in either of two ways:

Platform teams may make extension containers available across their clusters without installing every extension in every database. Install only the extensions a database uses; letting users enable them through SQL alongside the rest of their DDL schema management code can be a convenient approach.

For extensions that normally require superuser privileges, platform teams can use pgextwlist to allow non-superusers to install an administrator-approved selection of extensions.

3. Verify installation

Connect to the database with psql and run \dx to check the installed extensions.

After the library is preloaded and the extension is installed, inspect sampled waits:

SELECT event_type, event, sum(count) AS samples
FROM pg_wait_sampling_profile
GROUP BY event_type, event
ORDER BY samples DESC;

Supported matrix and licenses

The image supports PostgreSQL 18 on Debian Bookworm and Trixie. The PostgreSQL license notice is included under /licenses/postgresql-18-pg-wait-sampling/. Renovate tracks the versioned PGDG package.