pg_profile
pg_profile : PostgreSQL load profile repository and report builder
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 6000 | pg_profile
|
pg_profile
|
4.11 |
STAT
|
BSD 2-Clause
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d--
|
No
|
Yes
|
No
|
Yes
|
no
|
no
|
| Relationships | |
|---|---|
| Requires | dblink
plpgsql
|
| See Also | plprofiler
pg_stat_kcache
powa
pg_stat_statements
pg_show_plans
pg_stat_monitor
pg_qualstats
pg_store_plans
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED
|
4.11 |
18
17
16
15
14
|
pg_profile |
dblink, plpgsql |
| RPM | PGDG
|
4.11 |
18
17
16
15
14
|
pg_profile_$v |
- |
| DEB | PIGSTY
|
4.11 |
18
17
16
15
14
|
postgresql-$v-pg-profile |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
el8.aarch64
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
el9.x86_64
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
el9.aarch64
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
el10.x86_64
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
el10.aarch64
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
PGDG 4.11
|
d12.x86_64
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
d12.aarch64
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
d13.x86_64
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
d13.aarch64
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
u22.x86_64
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
u22.aarch64
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
u24.x86_64
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
u24.aarch64
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
PIGSTY 4.11
|
Source
pig build pkg pg_profile; # build debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install pg_profile; # install via package name, for the active PG version
pig install pg_profile -v 18; # install for PG 18
pig install pg_profile -v 17; # install for PG 17
pig install pg_profile -v 16; # install for PG 16
pig install pg_profile -v 15; # install for PG 15
pig install pg_profile -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION pg_profile CASCADE; -- requires dblink, plpgsqlUsage
pg_profile: historical performance profiling tool for PostgreSQL
pg_profile collects periodic samples of PostgreSQL statistics and generates detailed historical performance reports. It depends on pg_stat_statements and optionally uses pg_stat_kcache and pg_wait_sampling for additional metrics.
Taking Samples
Samples must be taken periodically (e.g., via cron). Each sample captures the current state of statistics:
SELECT profile.take_sample();Generating Reports
Build a report between two sample IDs to analyze performance during that interval:
-- Regular report between samples 1 and 2
SELECT profile.get_report(1, 2);
-- Differential report comparing two intervals
SELECT profile.get_diffreport(1, 2, 3, 4);Managing Servers
pg_profile can collect statistics from remote clusters:
-- Define a remote server
SELECT profile.create_server('remote', 'host=remote_host dbname=postgres');
-- List defined servers
SELECT * FROM profile.show_servers();
-- Enable/disable a server
SELECT profile.enable_server('remote');
SELECT profile.disable_server('remote');Baselines
Baselines protect sample ranges from automatic cleanup:
-- Create a baseline preserving samples 10 through 20
SELECT profile.create_baseline('incident_2024', 10, 20);
-- List baselines
SELECT * FROM profile.show_baselines();
-- Drop a baseline
SELECT profile.drop_baseline('incident_2024');Retention
Control how long samples are kept:
-- Set retention to 7 days for the local server
SELECT profile.set_server_max_sample_age('local', 7);Sample Information
-- Show available samples
SELECT * FROM profile.show_samples();
-- Show time spent taking samples (requires pg_profile.track_sample_timings = on)
SELECT * FROM v_sample_timings;Recommended Settings
track_activities = on
track_counts = on
track_io_timing = on
track_wal_io_timing = on # PG 14+
track_functions = all