plprofiler
plprofiler
plprofiler : server-side support for profiling PL/pgSQL functions
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3070 | plprofiler
|
plprofiler
|
4.2.5 |
LANG
|
Artistic
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--sLd-r
|
No
|
Yes
|
Yes
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | pldbgapi
plpgsql_check
plpgsql
pgtap
pg_profile
pg_stat_statements
pg_store_plans
auto_explain
|
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PGDG
|
4.2.5 |
18
17
16
15
14
|
plprofiler |
- |
| RPM | PGDG
|
4.2.5 |
18
17
16
15
14
|
plprofiler_$v |
- |
| DEB | PGDG
|
4.2.5 |
18
17
16
15
14
|
postgresql-$v-plprofiler |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
el8.aarch64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
el9.x86_64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
el9.aarch64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
el10.x86_64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
el10.aarch64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
d12.x86_64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
d12.aarch64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
d13.x86_64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
d13.aarch64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
u22.x86_64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
u22.aarch64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
u24.x86_64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
u24.aarch64
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
PGDG 4.2.5
|
Source
Install
Make sure PGDG repo available:
pig repo add pgdg -u # add pgdg repo and update cacheInstall this extension with pig:
pig install plprofiler; # install via package name, for the active PG version
pig install plprofiler -v 18; # install for PG 18
pig install plprofiler -v 17; # install for PG 17
pig install plprofiler -v 16; # install for PG 16
pig install plprofiler -v 15; # install for PG 15
pig install plprofiler -v 14; # install for PG 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'plprofiler';Create this extension with:
CREATE EXTENSION plprofiler;Usage
plprofiler: server-side support for profiling PL/pgSQL functions
plprofiler is a profiling tool for PL/pgSQL functions that identifies performance bottlenecks and generates interactive flame graph reports.
CREATE EXTENSION plprofiler;Configuration
Add to postgresql.conf:
shared_preload_libraries = 'plprofiler'Command-Line Tool
The plprofiler command-line utility controls profiling and generates reports:
# Profile a specific SQL command
plprofiler run -d mydb --command "SELECT my_function()" --output report.html
# Monitor profiling in real-time
plprofiler monitor -d mydb
# Save profiling data for later analysis
plprofiler save -d mydb --name "my_profile"
# Generate HTML report with flame graphs
plprofiler report -d mydb --from-data "my_profile" --output report.html
# List saved profiling datasets
plprofiler list -d mydb
# Reset profiling data
plprofiler reset-data -d mydb
# Export/import profiling data
plprofiler export -d mydb --from-data "my_profile" > profile.json
plprofiler import -d mydb --into-data "imported" < profile.jsonSQL Interface
-- Enable profiling for the current session
SELECT pl_profiler_set_enabled_local(true);
-- Execute functions to be profiled
SELECT my_function();
-- Collect profiling data into shared hash tables
SELECT pl_profiler_collect_data();
-- Disable profiling
SELECT pl_profiler_set_enabled_local(false);
-- Enable profiling globally (for all sessions)
SELECT pl_profiler_set_enabled_global(true);
-- Reset local/shared profiling data
SELECT pl_profiler_reset_local();
SELECT pl_profiler_reset_shared();Report Output
Generated HTML reports include:
- Interactive flame graphs showing wall-clock time spent in PL/pgSQL code
- Per-function statistics with self-time (total minus children)
- Top functions ranked by time consumption (default: top 10)
- Self-contained HTML requiring no external dependencies
Profiling Methods
- Direct profiling: Run specific SQL while collecting data
- Timed collection: Interval-based statistics gathering
- Per-user profiling: Enable profiling for specific database users via
ALTER USER - Production monitoring: Low-overhead profiling on live systems
Last updated on