跳转到主要内容

qos

QoS resource governor extension for PostgreSQL sessions and queries

pg_qos : QoS resource governor extension for PostgreSQL sessions and queries

Overview

ID Extension Package Version Category License Language
5240 qos pg_qos 1.1.0 ADMIN GPL-3.0-or-later C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd-- No Yes Yes Yes no no
Preload; restart on upgrade; Linux affinity.

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT PIGSTY 1.1.0 19 18 17 16 15 pg_qos -
RPM PIGSTY 1.1.0 19 18 17 16 15 pg_qos_$v -
DEB PIGSTY 1.1.0 19 18 17 16 15 postgresql-$v-qos -
Linux / PG PG19 PG18 PG17 PG16 PG15
el8.x86_64 N/A PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
el8.aarch64 N/A PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
el9.x86_64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
el9.aarch64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
el10.x86_64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
el10.aarch64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
d12.x86_64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
d12.aarch64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
d13.x86_64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
d13.aarch64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
u22.x86_64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
u22.aarch64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
u24.x86_64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
u24.aarch64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
u26.x86_64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
u26.aarch64 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0 PIGSTY 1.1.0
Package Version OS ORG SIZE File URL
pg_qos_19 1.1.0 el9.x86_64 pigsty 101.8 KiB pg_qos_19-1.1.0-1PGSTY.el9.x86_64.rpm
pg_qos_19 1.1.0 el9.aarch64 pigsty 100.5 KiB pg_qos_19-1.1.0-1PGSTY.el9.aarch64.rpm
pg_qos_19 1.1.0 el10.x86_64 pigsty 102.7 KiB pg_qos_19-1.1.0-1PGSTY.el10.x86_64.rpm
pg_qos_19 1.1.0 el10.aarch64 pigsty 101.2 KiB pg_qos_19-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-qos 1.1.0 d12.x86_64 pigsty 101.6 KiB postgresql-19-qos_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-qos 1.1.0 d12.aarch64 pigsty 99.2 KiB postgresql-19-qos_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-qos 1.1.0 d13.x86_64 pigsty 101.9 KiB postgresql-19-qos_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-19-qos 1.1.0 d13.aarch64 pigsty 99.4 KiB postgresql-19-qos_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-19-qos 1.1.0 u22.x86_64 pigsty 109.8 KiB postgresql-19-qos_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-19-qos 1.1.0 u22.aarch64 pigsty 107.8 KiB postgresql-19-qos_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-19-qos 1.1.0 u24.x86_64 pigsty 105.7 KiB postgresql-19-qos_1.1.0-1PGSTY~noble_amd64.deb
postgresql-19-qos 1.1.0 u24.aarch64 pigsty 104.7 KiB postgresql-19-qos_1.1.0-1PGSTY~noble_arm64.deb
postgresql-19-qos 1.1.0 u26.x86_64 pigsty 105.0 KiB postgresql-19-qos_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-19-qos 1.1.0 u26.aarch64 pigsty 103.4 KiB postgresql-19-qos_1.1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_qos_18 1.1.0 el8.x86_64 pigsty 99.8 KiB pg_qos_18-1.1.0-1PGSTY.el8.x86_64.rpm
pg_qos_18 1.1.0 el8.aarch64 pigsty 98.5 KiB pg_qos_18-1.1.0-1PGSTY.el8.aarch64.rpm
pg_qos_18 1.1.0 el9.x86_64 pigsty 101.2 KiB pg_qos_18-1.1.0-1PGSTY.el9.x86_64.rpm
pg_qos_18 1.1.0 el9.aarch64 pigsty 100.6 KiB pg_qos_18-1.1.0-1PGSTY.el9.aarch64.rpm
pg_qos_18 1.1.0 el10.x86_64 pigsty 101.5 KiB pg_qos_18-1.1.0-1PGSTY.el10.x86_64.rpm
pg_qos_18 1.1.0 el10.aarch64 pigsty 100.9 KiB pg_qos_18-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-qos 1.1.0 d12.x86_64 pigsty 100.3 KiB postgresql-18-qos_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-qos 1.1.0 d12.aarch64 pigsty 99.0 KiB postgresql-18-qos_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-qos 1.1.0 d13.x86_64 pigsty 100.6 KiB postgresql-18-qos_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-18-qos 1.1.0 d13.aarch64 pigsty 99.2 KiB postgresql-18-qos_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-18-qos 1.1.0 u22.x86_64 pigsty 108.6 KiB postgresql-18-qos_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-18-qos 1.1.0 u22.aarch64 pigsty 107.8 KiB postgresql-18-qos_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-18-qos 1.1.0 u24.x86_64 pigsty 104.3 KiB postgresql-18-qos_1.1.0-1PGSTY~noble_amd64.deb
postgresql-18-qos 1.1.0 u24.aarch64 pigsty 104.4 KiB postgresql-18-qos_1.1.0-1PGSTY~noble_arm64.deb
postgresql-18-qos 1.1.0 u26.x86_64 pigsty 104.0 KiB postgresql-18-qos_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-18-qos 1.1.0 u26.aarch64 pigsty 103.2 KiB postgresql-18-qos_1.1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_qos_17 1.1.0 el8.x86_64 pigsty 99.8 KiB pg_qos_17-1.1.0-1PGSTY.el8.x86_64.rpm
pg_qos_17 1.1.0 el8.aarch64 pigsty 98.5 KiB pg_qos_17-1.1.0-1PGSTY.el8.aarch64.rpm
pg_qos_17 1.1.0 el9.x86_64 pigsty 101.3 KiB pg_qos_17-1.1.0-1PGSTY.el9.x86_64.rpm
pg_qos_17 1.1.0 el9.aarch64 pigsty 100.7 KiB pg_qos_17-1.1.0-1PGSTY.el9.aarch64.rpm
pg_qos_17 1.1.0 el10.x86_64 pigsty 101.7 KiB pg_qos_17-1.1.0-1PGSTY.el10.x86_64.rpm
pg_qos_17 1.1.0 el10.aarch64 pigsty 101.1 KiB pg_qos_17-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-qos 1.1.0 d12.x86_64 pigsty 100.4 KiB postgresql-17-qos_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-qos 1.1.0 d12.aarch64 pigsty 99.0 KiB postgresql-17-qos_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-qos 1.1.0 d13.x86_64 pigsty 100.6 KiB postgresql-17-qos_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-17-qos 1.1.0 d13.aarch64 pigsty 99.3 KiB postgresql-17-qos_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-17-qos 1.1.0 u22.x86_64 pigsty 120.0 KiB postgresql-17-qos_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-17-qos 1.1.0 u22.aarch64 pigsty 119.3 KiB postgresql-17-qos_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-17-qos 1.1.0 u24.x86_64 pigsty 104.5 KiB postgresql-17-qos_1.1.0-1PGSTY~noble_amd64.deb
postgresql-17-qos 1.1.0 u24.aarch64 pigsty 104.6 KiB postgresql-17-qos_1.1.0-1PGSTY~noble_arm64.deb
postgresql-17-qos 1.1.0 u26.x86_64 pigsty 104.1 KiB postgresql-17-qos_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-17-qos 1.1.0 u26.aarch64 pigsty 103.3 KiB postgresql-17-qos_1.1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_qos_16 1.1.0 el8.x86_64 pigsty 99.6 KiB pg_qos_16-1.1.0-1PGSTY.el8.x86_64.rpm
pg_qos_16 1.1.0 el8.aarch64 pigsty 98.3 KiB pg_qos_16-1.1.0-1PGSTY.el8.aarch64.rpm
pg_qos_16 1.1.0 el9.x86_64 pigsty 101.1 KiB pg_qos_16-1.1.0-1PGSTY.el9.x86_64.rpm
pg_qos_16 1.1.0 el9.aarch64 pigsty 100.5 KiB pg_qos_16-1.1.0-1PGSTY.el9.aarch64.rpm
pg_qos_16 1.1.0 el10.x86_64 pigsty 101.5 KiB pg_qos_16-1.1.0-1PGSTY.el10.x86_64.rpm
pg_qos_16 1.1.0 el10.aarch64 pigsty 100.8 KiB pg_qos_16-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-qos 1.1.0 d12.x86_64 pigsty 100.2 KiB postgresql-16-qos_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-qos 1.1.0 d12.aarch64 pigsty 98.8 KiB postgresql-16-qos_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-qos 1.1.0 d13.x86_64 pigsty 100.5 KiB postgresql-16-qos_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-16-qos 1.1.0 d13.aarch64 pigsty 99.1 KiB postgresql-16-qos_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-16-qos 1.1.0 u22.x86_64 pigsty 118.2 KiB postgresql-16-qos_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-16-qos 1.1.0 u22.aarch64 pigsty 117.6 KiB postgresql-16-qos_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-16-qos 1.1.0 u24.x86_64 pigsty 104.4 KiB postgresql-16-qos_1.1.0-1PGSTY~noble_amd64.deb
postgresql-16-qos 1.1.0 u24.aarch64 pigsty 105.5 KiB postgresql-16-qos_1.1.0-1PGSTY~noble_arm64.deb
postgresql-16-qos 1.1.0 u26.x86_64 pigsty 104.0 KiB postgresql-16-qos_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-16-qos 1.1.0 u26.aarch64 pigsty 103.2 KiB postgresql-16-qos_1.1.0-1PGSTY~resolute_arm64.deb
Package Version OS ORG SIZE File URL
pg_qos_15 1.1.0 el8.x86_64 pigsty 99.8 KiB pg_qos_15-1.1.0-1PGSTY.el8.x86_64.rpm
pg_qos_15 1.1.0 el8.aarch64 pigsty 98.3 KiB pg_qos_15-1.1.0-1PGSTY.el8.aarch64.rpm
pg_qos_15 1.1.0 el9.x86_64 pigsty 101.5 KiB pg_qos_15-1.1.0-1PGSTY.el9.x86_64.rpm
pg_qos_15 1.1.0 el9.aarch64 pigsty 101.3 KiB pg_qos_15-1.1.0-1PGSTY.el9.aarch64.rpm
pg_qos_15 1.1.0 el10.x86_64 pigsty 101.7 KiB pg_qos_15-1.1.0-1PGSTY.el10.x86_64.rpm
pg_qos_15 1.1.0 el10.aarch64 pigsty 101.5 KiB pg_qos_15-1.1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-qos 1.1.0 d12.x86_64 pigsty 100.5 KiB postgresql-15-qos_1.1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-qos 1.1.0 d12.aarch64 pigsty 111.4 KiB postgresql-15-qos_1.1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-qos 1.1.0 d13.x86_64 pigsty 100.8 KiB postgresql-15-qos_1.1.0-1PGSTY~trixie_amd64.deb
postgresql-15-qos 1.1.0 d13.aarch64 pigsty 99.4 KiB postgresql-15-qos_1.1.0-1PGSTY~trixie_arm64.deb
postgresql-15-qos 1.1.0 u22.x86_64 pigsty 118.9 KiB postgresql-15-qos_1.1.0-1PGSTY~jammy_amd64.deb
postgresql-15-qos 1.1.0 u22.aarch64 pigsty 118.5 KiB postgresql-15-qos_1.1.0-1PGSTY~jammy_arm64.deb
postgresql-15-qos 1.1.0 u24.x86_64 pigsty 104.8 KiB postgresql-15-qos_1.1.0-1PGSTY~noble_amd64.deb
postgresql-15-qos 1.1.0 u24.aarch64 pigsty 105.0 KiB postgresql-15-qos_1.1.0-1PGSTY~noble_arm64.deb
postgresql-15-qos 1.1.0 u26.x86_64 pigsty 104.1 KiB postgresql-15-qos_1.1.0-1PGSTY~resolute_amd64.deb
postgresql-15-qos 1.1.0 u26.aarch64 pigsty 103.8 KiB postgresql-15-qos_1.1.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_qos;		# 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_qos;		# install via package name, for the active PG version
pig install qos;		# install by extension name, for the current active PG version

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

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'qos';

Create this extension with:

CREATE EXTENSION qos;

Usage

Sources:

qos 1.1 (distribution 1.1.0) applies per-role and per-database resource limits on PostgreSQL 15+. Merge qos into shared_preload_libraries and restart before creating its SQL objects as an administrator. CPU affinity limits require Linux.

Configure Limits

CREATE EXTENSION qos;
ALTER ROLE app_user SET qos.work_mem_limit = '32MB';
ALTER ROLE app_user SET qos.max_concurrent_select = '100';
ALTER ROLE app_user SET qos.max_select_rate = '10/500ms';
SELECT * FROM qos_stat_rate;

Limit Semantics

qos.work_mem_limit caps effective work memory; qos.cpu_core_limit controls CPU affinity on Linux and limits parallel workers on other platforms. qos.max_concurrent_tx, qos.max_concurrent_select, qos.max_concurrent_update, qos.max_concurrent_delete and qos.max_concurrent_insert cap concurrent operations.

qos.max_tx_rate, qos.max_select_rate, qos.max_update_rate, qos.max_delete_rate and qos.max_insert_rate use count/window pairs such as 100/1s. The default -1 disables each rate limit. Windows range from 100 ms to one day. Rate and concurrency violations raise SQLSTATE 54000; clients should use the retry hint. The most restrictive applicable role/database setting wins, and rate pairs are compared by normalized rate.

Observability and Upgrade

qos_stat_rate exposes live windows; the other qos_stat views expose activity and counters. qos_prometheus_metrics() renders Prometheus exposition text. Counters reset at server restart. Version 1.1 replaces the old nonfunctional qos_get_stats() with these views.

Upgrading requires replacing the library and restarting PostgreSQL because the shared-memory layout changes, followed by ALTER EXTENSION qos UPDATE TO '1.1' in each database. New rate limits stay disabled until configured. These controls do not replace application admission limits or operating-system isolation.

表格阅读器