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

ID Extension Package Version Category License Language
6230 pg_rusage pg_rusage 1.0 STAT PostgreSQL C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r No Yes No Yes yes no
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

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 1.0 18 17 16 15 14 pg_rusage -
RPM PIGSTY 1.0 18 17 16 15 14 pg_rusage_$v -
DEB PIGSTY 1.0 18 17 16 15 14 postgresql-$v-pg-rusage -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el8.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el9.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el9.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el10.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
el10.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
d12.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
d12.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
d13.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
d13.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u22.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u22.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u24.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u24.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u26.x86_64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
u26.aarch64 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0 PIGSTY 1.0
Package Version OS ORG SIZE File URL
pg_rusage_18 1.0 el8.x86_64 pigsty 16.8 KiB pg_rusage_18-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_18 1.0 el8.aarch64 pigsty 16.9 KiB pg_rusage_18-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_18 1.0 el9.x86_64 pigsty 16.7 KiB pg_rusage_18-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_18 1.0 el9.aarch64 pigsty 16.6 KiB pg_rusage_18-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_18 1.0 el10.x86_64 pigsty 16.7 KiB pg_rusage_18-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_18 1.0 el10.aarch64 pigsty 16.8 KiB pg_rusage_18-1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-rusage 1.0 d12.x86_64 pigsty 7.4 KiB postgresql-18-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-rusage 1.0 d12.aarch64 pigsty 7.5 KiB postgresql-18-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-rusage 1.0 d13.x86_64 pigsty 7.4 KiB postgresql-18-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-rusage 1.0 d13.aarch64 pigsty 7.6 KiB postgresql-18-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-rusage 1.0 u22.x86_64 pigsty 7.4 KiB postgresql-18-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-rusage 1.0 u22.aarch64 pigsty 7.4 KiB postgresql-18-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-rusage 1.0 u24.x86_64 pigsty 7.7 KiB postgresql-18-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-rusage 1.0 u24.aarch64 pigsty 7.7 KiB postgresql-18-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-rusage 1.0 u26.x86_64 pigsty 7.8 KiB postgresql-18-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-rusage 1.0 u26.aarch64 pigsty 7.9 KiB postgresql-18-pg-rusage_1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_rusage_17 1.0 el8.x86_64 pigsty 16.8 KiB pg_rusage_17-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_17 1.0 el8.aarch64 pigsty 16.9 KiB pg_rusage_17-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_17 1.0 el9.x86_64 pigsty 16.6 KiB pg_rusage_17-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_17 1.0 el9.aarch64 pigsty 16.5 KiB pg_rusage_17-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_17 1.0 el10.x86_64 pigsty 16.7 KiB pg_rusage_17-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_17 1.0 el10.aarch64 pigsty 16.8 KiB pg_rusage_17-1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-rusage 1.0 d12.x86_64 pigsty 7.4 KiB postgresql-17-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-rusage 1.0 d12.aarch64 pigsty 7.5 KiB postgresql-17-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-rusage 1.0 d13.x86_64 pigsty 7.4 KiB postgresql-17-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-rusage 1.0 d13.aarch64 pigsty 7.5 KiB postgresql-17-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-rusage 1.0 u22.x86_64 pigsty 7.5 KiB postgresql-17-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-rusage 1.0 u22.aarch64 pigsty 7.5 KiB postgresql-17-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-rusage 1.0 u24.x86_64 pigsty 7.7 KiB postgresql-17-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-rusage 1.0 u24.aarch64 pigsty 7.6 KiB postgresql-17-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-rusage 1.0 u26.x86_64 pigsty 7.8 KiB postgresql-17-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-rusage 1.0 u26.aarch64 pigsty 7.9 KiB postgresql-17-pg-rusage_1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_rusage_16 1.0 el8.x86_64 pigsty 16.8 KiB pg_rusage_16-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_16 1.0 el8.aarch64 pigsty 16.9 KiB pg_rusage_16-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_16 1.0 el9.x86_64 pigsty 16.6 KiB pg_rusage_16-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_16 1.0 el9.aarch64 pigsty 16.5 KiB pg_rusage_16-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_16 1.0 el10.x86_64 pigsty 16.7 KiB pg_rusage_16-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_16 1.0 el10.aarch64 pigsty 16.8 KiB pg_rusage_16-1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-rusage 1.0 d12.x86_64 pigsty 7.4 KiB postgresql-16-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-rusage 1.0 d12.aarch64 pigsty 7.5 KiB postgresql-16-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-rusage 1.0 d13.x86_64 pigsty 7.4 KiB postgresql-16-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-rusage 1.0 d13.aarch64 pigsty 7.5 KiB postgresql-16-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-rusage 1.0 u22.x86_64 pigsty 7.5 KiB postgresql-16-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-rusage 1.0 u22.aarch64 pigsty 7.5 KiB postgresql-16-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-rusage 1.0 u24.x86_64 pigsty 7.6 KiB postgresql-16-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-rusage 1.0 u24.aarch64 pigsty 7.6 KiB postgresql-16-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-rusage 1.0 u26.x86_64 pigsty 7.8 KiB postgresql-16-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-rusage 1.0 u26.aarch64 pigsty 7.9 KiB postgresql-16-pg-rusage_1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_rusage_15 1.0 el8.x86_64 pigsty 16.8 KiB pg_rusage_15-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_15 1.0 el8.aarch64 pigsty 16.9 KiB pg_rusage_15-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_15 1.0 el9.x86_64 pigsty 16.6 KiB pg_rusage_15-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_15 1.0 el9.aarch64 pigsty 16.5 KiB pg_rusage_15-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_15 1.0 el10.x86_64 pigsty 16.7 KiB pg_rusage_15-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_15 1.0 el10.aarch64 pigsty 16.8 KiB pg_rusage_15-1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-rusage 1.0 d12.x86_64 pigsty 7.4 KiB postgresql-15-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-rusage 1.0 d12.aarch64 pigsty 7.5 KiB postgresql-15-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-rusage 1.0 d13.x86_64 pigsty 7.4 KiB postgresql-15-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-rusage 1.0 d13.aarch64 pigsty 7.5 KiB postgresql-15-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-rusage 1.0 u22.x86_64 pigsty 7.5 KiB postgresql-15-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-rusage 1.0 u22.aarch64 pigsty 7.5 KiB postgresql-15-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-rusage 1.0 u24.x86_64 pigsty 7.7 KiB postgresql-15-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-rusage 1.0 u24.aarch64 pigsty 7.6 KiB postgresql-15-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-rusage 1.0 u26.x86_64 pigsty 7.8 KiB postgresql-15-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-rusage 1.0 u26.aarch64 pigsty 7.9 KiB postgresql-15-pg-rusage_1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_rusage_14 1.0 el8.x86_64 pigsty 16.8 KiB pg_rusage_14-1.0-1PGSTY.el8.x86_64.rpm
pg_rusage_14 1.0 el8.aarch64 pigsty 16.8 KiB pg_rusage_14-1.0-1PGSTY.el8.aarch64.rpm
pg_rusage_14 1.0 el9.x86_64 pigsty 16.6 KiB pg_rusage_14-1.0-1PGSTY.el9.x86_64.rpm
pg_rusage_14 1.0 el9.aarch64 pigsty 16.5 KiB pg_rusage_14-1.0-1PGSTY.el9.aarch64.rpm
pg_rusage_14 1.0 el10.x86_64 pigsty 16.7 KiB pg_rusage_14-1.0-1PGSTY.el10.x86_64.rpm
pg_rusage_14 1.0 el10.aarch64 pigsty 16.8 KiB pg_rusage_14-1.0-1PGSTY.el10.aarch64.rpm
postgresql-14-pg-rusage 1.0 d12.x86_64 pigsty 8.0 KiB postgresql-14-pg-rusage_1.0-1PGSTY~bookworm_amd64.deb
postgresql-14-pg-rusage 1.0 d12.aarch64 pigsty 8.1 KiB postgresql-14-pg-rusage_1.0-1PGSTY~bookworm_arm64.deb
postgresql-14-pg-rusage 1.0 d13.x86_64 pigsty 8.0 KiB postgresql-14-pg-rusage_1.0-1PGSTY~trixie_amd64.deb
postgresql-14-pg-rusage 1.0 d13.aarch64 pigsty 8.1 KiB postgresql-14-pg-rusage_1.0-1PGSTY~trixie_arm64.deb
postgresql-14-pg-rusage 1.0 u22.x86_64 pigsty 8.1 KiB postgresql-14-pg-rusage_1.0-1PGSTY~jammy_amd64.deb
postgresql-14-pg-rusage 1.0 u22.aarch64 pigsty 8.2 KiB postgresql-14-pg-rusage_1.0-1PGSTY~jammy_arm64.deb
postgresql-14-pg-rusage 1.0 u24.x86_64 pigsty 8.3 KiB postgresql-14-pg-rusage_1.0-1PGSTY~noble_amd64.deb
postgresql-14-pg-rusage 1.0 u24.aarch64 pigsty 8.2 KiB postgresql-14-pg-rusage_1.0-1PGSTY~noble_arm64.deb
postgresql-14-pg-rusage 1.0 u26.x86_64 pigsty 8.5 KiB postgresql-14-pg-rusage_1.0-1PGSTY~resolute_amd64.deb
postgresql-14-pg-rusage 1.0 u26.aarch64 pigsty 8.5 KiB postgresql-14-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 via package name, for the active PG version

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
pig install pg_rusage -v 14;   # install for PG 14

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.