Skip to content

prioritize

get and set the priority of PostgreSQL backends

Overview

PackageVersionCategoryLicenseLanguage
pg_prioritize1.0.4ADMINPostgreSQLC
IDExtensionBinLibLoadCreateTrustRelocSchema
5100prioritizeNoYesNoYesNoYes-

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG1.0.41817161514pg_prioritize-
RPMPGDG1.0.41817161514pg_prioritize_$v-
DEBPGDG1.0.41817161514postgresql-$v-prioritize-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
PGDG 1.0.4
PGDG 1.0.4
el8.aarch64
PGDG 1.0.4
PGDG 1.0.4
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
d12.aarch64
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
d13.x86_64
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
d13.aarch64
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
u22.x86_64
u22.aarch64
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
u24.x86_64
u24.aarch64
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
u26.x86_64
u26.aarch64
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4
PGDG 1.0.4

Install

You can install pg_prioritize directly. First, make sure the PGDG repository is added and enabled:

pig repo add pgdg -u          # Add PGDG repo and update cache

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

Install
pig install pg_prioritize;          # Install for current active PG version
pig
pig ext install -y pg_prioritize -v 18  # PG 18
pig ext install -y pg_prioritize -v 17  # PG 17
pig ext install -y pg_prioritize -v 16  # PG 16
pig ext install -y pg_prioritize -v 15  # PG 15
pig ext install -y pg_prioritize -v 14  # PG 14
dnf
dnf install -y pg_prioritize_18       # PG 18
dnf install -y pg_prioritize_17       # PG 17
dnf install -y pg_prioritize_16       # PG 16
dnf install -y pg_prioritize_15       # PG 15
dnf install -y pg_prioritize_14       # PG 14
apt
apt install -y postgresql-18-prioritize   # PG 18
apt install -y postgresql-17-prioritize   # PG 17
apt install -y postgresql-16-prioritize   # PG 16
apt install -y postgresql-15-prioritize   # PG 15
apt install -y postgresql-14-prioritize   # PG 14

Create Extension:

CREATE EXTENSION prioritize;

Usage

Sources:

prioritize exposes operating-system priority controls for PostgreSQL backend processes. Use it to lower the scheduling priority of selected sessions; it is not a PostgreSQL query scheduler.

Inspect and Adjust a Backend

CREATE EXTENSION prioritize;
SELECT get_backend_priority(pg_backend_pid());
SELECT set_backend_priority(pg_backend_pid(), 10);

Any user may query a backend’s priority. A PostgreSQL superuser may request adjustments for any backend; other users may adjust only backends running under the same database role.

SELECT set_backend_priority(pid, get_backend_priority(pid) + 5)
FROM pg_stat_activity
WHERE usename = CURRENT_USER;

Increasing the numeric nice value lowers operating-system scheduling priority. The example therefore reduces those backends’ priority, rather than speeding them up.

Privileges and Limits

Installation requires a superuser, with no preload or restart. Operating-system permissions still apply: ordinary PostgreSQL processes normally cannot lower the numeric nice value to increase priority. Database superuser privileges do not confer root privileges. Review platform scheduling policy and process identity before using bulk adjustments. The control file uses SQL version 1.0; distribution package version 1.0.4 is separate.

Was this page helpful?