pg_store_plans
pg_store_plans : track plan statistics of all SQL statements executed
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 6250 | pg_store_plans | pg_store_plans | 1.10 |
STAT | BSD-3-Clause | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-r | No | Yes | Yes | Yes | yes | no |
| Relationships | |
|---|---|
| See Also | pg_stat_plans pg_profile pg_stat_monitor pg_show_plans pg_stat_statements auto_explain explain_ui powa pg_overexplain pg_wait_sampling |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 1.10 |
18 17 16 15 14 | pg_store_plans |
- |
| RPM | PIGSTY | 1.10 |
18 17 16 15 14 | pg_store_plans_$v |
- |
| DEB | PIGSTY | 1.10 |
18 17 16 15 14 | postgresql-$v-pg-store-plan |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| el8.aarch64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| el9.x86_64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| el9.aarch64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| el10.x86_64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| el10.aarch64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| d12.x86_64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| d12.aarch64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| d13.x86_64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| d13.aarch64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| u22.x86_64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| u22.aarch64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| u24.x86_64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| u24.aarch64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| u26.x86_64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
| u26.aarch64 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 | PIGSTY 1.10 |
Source
github.com/ossc-db/pg_store_plans
pg_store_plans-1.10.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
Sources: official docs, repo, 1.10 release notes
pg_store_plans tracks execution plan statistics for SQL statements, similar to how pg_stat_statements tracks statement statistics. The upstream 1.10 release note says this version adds PostgreSQL 18 support; the documented SQL surface is otherwise the same as current docs.
Required server settings
pg_store_plans requires shared memory, so adding or removing it needs a server restart. The docs say it is silently disabled if compute_query_id is no.
Inspect stored plans
The docs describe queryid as the join key for pg_stat_statements, and pg_store_plans_info as a one-row view that exposes module-level stats such as dealloc and stats_reset.
Helper functions
pg_store_plans_*plan() is useful when pg_store_plans.plan_format = 'raw'.
Key GUCs
pg_store_plans.maxpg_store_plans.trackpg_store_plans.max_plan_lengthpg_store_plans.plan_storagepg_store_plans.plan_formatpg_store_plans.min_durationpg_store_plans.log_analyzepg_store_plans.log_bufferspg_store_plans.log_timingpg_store_plans.save
The docs describe plan_storage as file or shmem, and plan_format as text, json, xml, yaml, or raw.
Caveats
- Non-superusers cannot see
plan,queryid, orplanidfor statements executed by other users. pg_store_plansandpg_stat_statementsmaintain entries independently, so low-frequency rows may not always have a matching peer.