Diagnostic step 1
Collect EXPLAIN (ANALYZE, VERBOSE) for both the prepared (generic) and simple/custom plans to confirm differences and capture estimated vs actual row counts.
Generated Oct 3, 2026, 12:35:03 AM
Collect EXPLAIN (ANALYZE, VERBOSE) for both the prepared (generic) and simple/custom plans to confirm differences and capture estimated vs actual row counts.
Modify the application to avoid long-lived prepared statements for highly selective queries (e.g., reprepare per-connection or use parameter passing mode that forces custom plans), or explicitly close and reprepare statements after maintenance windows.
Test setting plan_cache_mode = 'force_custom_plan' (if available in your PostgreSQL minor release) in a safe staging environment to evaluate impact; this forces per-execution planning at the cost of CPU.
Consider refactoring queries to be more stable in selectivity (e.g., rewrite to include partition key constants where possible) or add partial indexes on common query patterns.
If changes are unclear or impact is large, engage a DBA to review query patterns and recommend whether architectural changes (partition pruning improvements, use of prepared statements, or upgrade path) are most appropriate.