Skip to content

pg_rusage

Measure backend CPU usage between explicit reset and print calls

pg_rusage · Measure backend CPU usage between explicit reset and print calls

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
6230pg_rusagepg_rusage1.0STATPostgreSQLC
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-rNoYesNoYesyesno
pg_rusage_print() emits the current backend measurement as a WARNING and returns void. No preload; PostgreSQL 14-18 verified in PGSTY builds; upstream declares no major-version matrix.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY1.019 18 17 16 15pg_rusage-
RPMPIGSTY1.019 18 17 16 15pg_rusage_$v-
DEBPIGSTY1.019 18 17 16 15postgresql-$v-pg-rusage-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el8.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
PackageVersionOSORGSIZEFile URL
pg_rusage_181.0el8.x86_64pigsty16.6 KiBpg_rusage_18-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_181.0el8.aarch64pigsty16.9 KiBpg_rusage_18-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_181.0el9.x86_64pigsty16.8 KiBpg_rusage_18-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_181.0el9.aarch64pigsty16.7 KiBpg_rusage_18-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_181.0el10.x86_64pigsty16.8 KiBpg_rusage_18-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_181.0el10.aarch64pigsty16.8 KiBpg_rusage_18-1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-rusage1.0d12.x86_64pigsty8.1 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-rusage1.0d12.aarch64pigsty8.1 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-rusage1.0d13.x86_64pigsty8.0 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-rusage1.0d13.aarch64pigsty8.2 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-rusage1.0u22.x86_64pigsty8.1 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-rusage1.0u22.aarch64pigsty8.1 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-rusage1.0u24.x86_64pigsty8.4 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-rusage1.0u24.aarch64pigsty8.3 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-rusage1.0u26.x86_64pigsty8.5 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-rusage1.0u26.aarch64pigsty8.6 KiBpostgresql-18-pg-rusage_1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_rusage_171.0el8.x86_64pigsty16.6 KiBpg_rusage_17-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_171.0el8.aarch64pigsty16.8 KiBpg_rusage_17-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_171.0el9.x86_64pigsty16.7 KiBpg_rusage_17-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_171.0el9.aarch64pigsty16.7 KiBpg_rusage_17-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_171.0el10.x86_64pigsty16.7 KiBpg_rusage_17-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_171.0el10.aarch64pigsty16.8 KiBpg_rusage_17-1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-rusage1.0d12.x86_64pigsty8.0 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-rusage1.0d12.aarch64pigsty8.1 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-rusage1.0d13.x86_64pigsty8.0 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-rusage1.0d13.aarch64pigsty8.1 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-rusage1.0u22.x86_64pigsty8.1 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-rusage1.0u22.aarch64pigsty8.2 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-rusage1.0u24.x86_64pigsty8.3 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-rusage1.0u24.aarch64pigsty8.3 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-rusage1.0u26.x86_64pigsty8.5 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-rusage1.0u26.aarch64pigsty8.6 KiBpostgresql-17-pg-rusage_1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_rusage_161.0el8.x86_64pigsty16.6 KiBpg_rusage_16-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_161.0el8.aarch64pigsty16.8 KiBpg_rusage_16-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_161.0el9.x86_64pigsty16.8 KiBpg_rusage_16-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_161.0el9.aarch64pigsty16.7 KiBpg_rusage_16-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_161.0el10.x86_64pigsty16.7 KiBpg_rusage_16-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_161.0el10.aarch64pigsty16.8 KiBpg_rusage_16-1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-rusage1.0d12.x86_64pigsty8.0 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-rusage1.0d12.aarch64pigsty8.1 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-rusage1.0d13.x86_64pigsty8.0 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-rusage1.0d13.aarch64pigsty8.1 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-rusage1.0u22.x86_64pigsty8.1 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-rusage1.0u22.aarch64pigsty8.2 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-rusage1.0u24.x86_64pigsty8.3 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-rusage1.0u24.aarch64pigsty8.3 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-rusage1.0u26.x86_64pigsty8.5 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-rusage1.0u26.aarch64pigsty8.5 KiBpostgresql-16-pg-rusage_1.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_rusage_151.0el8.x86_64pigsty16.6 KiBpg_rusage_15-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_151.0el8.aarch64pigsty16.8 KiBpg_rusage_15-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_151.0el9.x86_64pigsty16.8 KiBpg_rusage_15-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_151.0el9.aarch64pigsty16.7 KiBpg_rusage_15-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_151.0el10.x86_64pigsty16.7 KiBpg_rusage_15-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_151.0el10.aarch64pigsty16.8 KiBpg_rusage_15-1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-rusage1.0d12.x86_64pigsty8.0 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-rusage1.0d12.aarch64pigsty8.1 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-rusage1.0d13.x86_64pigsty8.0 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-rusage1.0d13.aarch64pigsty8.1 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-rusage1.0u22.x86_64pigsty8.1 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-rusage1.0u22.aarch64pigsty8.2 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-rusage1.0u24.x86_64pigsty8.3 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-rusage1.0u24.aarch64pigsty8.3 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-rusage1.0u26.x86_64pigsty8.5 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-rusage1.0u26.aarch64pigsty8.6 KiBpostgresql-15-pg-rusage_1.0-1PGSTY~resolute_arm64.deb

Source

github.com/michaelpq/pg_plugins/tree/ae57c1f3df697fb942f4576f873a655187193ace/pg_rusage

pig build pkg pg_rusage;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_rusage;		# install by package name

pig install pg_rusage -v 19;   # install for PG 19
pig install pg_rusage -v 18;   # install for PG 18
pig install pg_rusage -v 17;   # install for PG 17
pig install pg_rusage -v 16;   # install for PG 16
pig install pg_rusage -v 15;   # install for PG 15

Create this extension with:

CREATE EXTENSION pg_rusage;

Usage

Sources:

pg_rusage — This module is a PostgreSQL extension that can enable CPU measurements, with one SQL function to enable the measurement and one to disable it. When disabling, the existing accumulated results will show up. Use it when collecting or interpreting the corresponding PostgreSQL statistics. Use the pinned upstream revision linked above as the API boundary and test it on the target PostgreSQL build.

Core Workflow

CREATE EXTENSION pg_rusage;

Install the extension in the intended database, run the smallest upstream example above when available, and verify the installed version and returned values before integrating it into application SQL.

Important Objects

  • pg_rusage_print() is an extension function and returns void.
  • pg_rusage_reset() is an extension function and returns void.

Requirements and Caveats

  • The reviewed control file declares default version 1.0.
  • The control file marks the extension as relocatable.
  • Confirm privileges, supported PostgreSQL versions, upgrade behavior, and failure cases against the pinned source before production use.

Table reader