plan_filter
pg_plan_filter : filter statements by their execution plans.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2810 | plan_filter | pg_plan_filter | 1.0.0 |
FEAT | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sL--- | No | Yes | Yes | No | no | no |
| Relationships | |
|---|---|
| See Also | pg_hint_plan pg_kpart pg_command_fw hypopg index_advisor pg_qualstats online_advisor block_copy_command pg_stat_plans pg_readonly |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.0.0 |
18 17 16 15 14 | pg_plan_filter |
- |
| RPM | PIGSTY | 1.0.0 |
18 17 16 15 14 | pg_plan_filter_$v |
- |
| DEB | PIGSTY | 1.0.0 |
18 17 16 15 14 | postgresql-$v-pg-plan-filter |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 |
| el8.aarch64 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 |
| el9.x86_64 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 |
| el9.aarch64 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 |
| el10.x86_64 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 |
| el10.aarch64 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 | PGDG 1.0.0 |
| d12.x86_64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| d12.aarch64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| d13.x86_64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| d13.aarch64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| u22.x86_64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| u22.aarch64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| u24.x86_64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| u24.aarch64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| u26.x86_64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
| u26.aarch64 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 | PIGSTY 0.0.1 |
Source
github.com/pgexperts/pg_plan_filter
pg_plan_filter-1.0.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
This extension does not need CREATE EXTENSION DDL command
Usage
Sources:
plan_filter is the loadable library in pg_plan_filter 1.0.0. It rejects statements or transactions whose estimated plan cost exceeds configured limits. It supports PostgreSQL 14–18 and has no SQL extension to create.
Core Workflow
Operational Boundaries
Append the library to the existing preload list and restart; LOAD is also supported for development and testing. Both cost limits default to zero, disabling enforcement. plan_filter.statement_cost_limit caps a single plan and can also reject expensive plain EXPLAIN. plan_filter.transaction_cost_limit charges every execution, including repeated prepared statements; rolling back to a savepoint does not refund the budget. Plain EXPLAIN does not consume the transaction budget, while plan-bearing utility commands do.
plan_filter.filter_select_only applies both limits only to SELECT when true; SELECT can still have side effects. plan_filter.module_loaded is a read-only presence signal. The limit settings require superuser or explicitly granted parameter-setting privileges. Rejection uses SQLSTATE 54001. Cost is an estimate rather than elapsed time, and ordinary roles can lower planner cost settings to evade the threshold. Use this as cooperative protection against accidental load, not as the sole security boundary against hostile sessions.