1min.

1MIN · DATABASES

pg_plan_filter can reject costly query plans before execution

pg_plan_filter 1.0.0 lets PostgreSQL administrators reject statements whose estimated plan cost exceeds a configured limit. It can also cap the combined estimated cost of statements within a transaction, preventing many individually small queries from accumulating unlimited planned work. An optional setting restricts filtering to SELECT statements, though SELECT does not always mean read-only.

PGX, Inc. · Oct 7, 2026

Why it matters

This provides an additional guard for applications that submit variable or generated SQL against production databases.

More context

Try it on PostgreSQL 14 through 18 in a test environment. The documented production setup preloads the module; limits default to zero, so loading it alone enables no filtering. Threshold settings require administrator privileges. Evaluate realistic plans before choosing limits.

Keep in mind

Planner cost is an estimate, not elapsed time or an exact resource budget. Most statements without a plan are outside the accounting. This complements other controls rather than replacing timeouts or access restrictions; we have not tested it.

Original read

More engineering ideas, one minute at a time.

Explore more stories