Skip to content

pg_control_priority

Controls scheduling priorities (nice values) of PostgreSQL server processes.

pg_control_priority · Controls scheduling priorities (nice values) of PostgreSQL server processes.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100179pg_control_prioritypg_control_priority1.0ADMINPostgreSQLC

PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18

Usage

Sources:

pg_control_priority 1.0 reads or raises the POSIX nice value of a PostgreSQL process. A larger numeric nice value means less CPU scheduling priority; this does not control query, lock, storage, or network priority.

Deprioritize the current test session

CREATE EXTENSION pg_control_priority;
SELECT pg_get_priority(pg_backend_pid());
SELECT pg_set_priority(pg_backend_pid(), 5);
SELECT pg_get_priority(pg_backend_pid());

Run this in a disposable session because the backend remains deprioritized until it exits. The install SQL revokes public execution of both functions, so the calls require superuser access or an explicit grant.

Startup configuration

To apply the scheduling-priority setting consistently, preload the library and restart:

shared_preload_libraries = 'pg_control_priority'
pg_control_priority.scheduling_priority = 5

Caveats

  • A PostgreSQL process can normally lower its own CPU priority but cannot raise it again without operating-system privilege. On common Unix systems the effective nice range ends at 19 even though the setting accepts 20.
  • Supplying another PostgreSQL process identifier can affect client backends, auxiliary processes, or the postmaster when operating-system permissions allow it. Keep execution tightly restricted.
  • The code uses PostgreSQL process checks and Unix scheduling APIs. It is not portable to Windows and must be built and tested for the exact PostgreSQL and operating-system target.

Table reader