Skip to content

pgmeminfo

show memory usage

Overview

PackageVersionCategoryLicenseLanguage
pgmeminfo1.0.1STATMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
6520pgmeminfoNoYesNoYesNoNo-

Version

TypeRepoVersionPG VerPackageDeps
EXTMIXED1.0.11817161514pgmeminfo-
RPMPIGSTY1.0.11817161514pgmeminfo_$v-
DEBPIGSTY1.0.11817161514postgresql-$v-pgmeminfo-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
d13.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u22.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u22.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u24.x86_64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u24.aarch64
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
PIGSTY 1.0.0
u26.x86_64
u26.aarch64

Build

You can build the RPM / DEB packages for pgmeminfo using pig build:

pig build pkg pgmeminfo         # build RPM / DEB packages

Install

You can install pgmeminfo directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

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

Install the extension using pig or apt/yum/dnf:

Install
pig install pgmeminfo;          # Install for current active PG version
pig
pig ext install -y pgmeminfo -v 18  # PG 18
pig ext install -y pgmeminfo -v 17  # PG 17
pig ext install -y pgmeminfo -v 16  # PG 16
pig ext install -y pgmeminfo -v 15  # PG 15
pig ext install -y pgmeminfo -v 14  # PG 14
dnf
dnf install -y pgmeminfo_18       # PG 18
dnf install -y pgmeminfo_17       # PG 17
dnf install -y pgmeminfo_16       # PG 16
dnf install -y pgmeminfo_15       # PG 15
dnf install -y pgmeminfo_14       # PG 14
apt
apt install -y postgresql-18-pgmeminfo   # PG 18
apt install -y postgresql-17-pgmeminfo   # PG 17
apt install -y postgresql-16-pgmeminfo   # PG 16
apt install -y postgresql-15-pgmeminfo   # PG 15
apt install -y postgresql-14-pgmeminfo   # PG 14

Create Extension:

CREATE EXTENSION pgmeminfo;

Usage

Sources:

pgmeminfo reports allocator statistics and the memory-context hierarchy of the current PostgreSQL backend. It does not aggregate memory across the cluster.

Inspect Memory

Have a superuser install the extension, then inspect the current connection:

CREATE EXTENSION pgmeminfo;
SELECT * FROM pgmeminfo();
SELECT * FROM pgmeminfo_contexts();
SELECT * FROM pgmeminfo_contexts(deep => 1);
SELECT * FROM pgmeminfo_contexts(deep => -1, accum_mode => 'off');

pgmeminfo() returns allocator counters such as arena, uordblks, fordblks, and keepcost. They are allocator-specific measurements, not process RSS or an estimate of free cluster memory.

pgmeminfo_contexts(deep, accum_mode) returns context names, parents, levels and byte counts. The default accumulation mode is all; off reports contexts without descendant accumulation, while deep => -1 removes the depth limit.

Operation and Version

No preload or restart is required. Upstream release 1.0.1 keeps SQL extension version 1.0; do not use package release 1.0.1 as an SQL update target. Context names and output values can change as the backend executes queries. Review function access if internal context names should not be visible to ordinary users.

Was this page helpful?