Part of the PostgreSQL parity effort (#2530). This is the largest single gap and probably wants breaking down further before anyone starts.
The gap
For SQL Server we have a whole plan family: analyze_query_plan, analyze_procedure_plan, analyze_query_store_plan, analyze_plan_xml, get_plan_xml, the graphical plan viewer, plan-cache bloat reads, plan corrections. For PostgreSQL we capture no plans at all — git grep for auto_explain, EXPLAIN (, pg_stat_plans across the collectors and service returns nothing, and docs/uat-onboarding.md already admits it: "no plan capture or blocking-chain read" for pg targets.
Datadog DBM captures explain plans for Postgres via sampling, and plans are the reason people open a database monitoring tool at all. Someone evaluating us against DBM on Aurora reaches this within the first hour.
What already exists to build on
PgStatementStatsCollector already collects pg_stat_statements (and aurora_stat_statements() on Aurora), so the query side is there — queryid, calls, timing. What is missing is the plan for a given queryid.
The mechanisms, which need a decision
auto_explain — logs plans for statements over a duration threshold. Needs a shared-library preload and carries a per-statement cost; on RDS/Aurora it is a parameter-group change, not something the monitoring tool can switch on for itself.
pg_stat_plans / similar extensions — record plans alongside statements, but extension availability on managed Postgres is the constraint.
- On-demand
EXPLAIN — the tool runs EXPLAIN for a query it has already seen. No preload needed, but the plan is now, not the plan from when it was slow, and parameters have to come from somewhere.
The third is the only one that works with no server-side configuration, and it is also the weakest evidence. That trade is the substance of this issue.
Constraints worth naming up front
- Aurora and RDS restrict
shared_preload_libraries to parameter groups and a restart, so anything requiring a preload is a customer action we can detect and advise on, not something we can arrange.
- Plan capture on a busy server is expensive; whatever ships needs the same sampling discipline the SQL Server side already applies.
- The MCP surface should be able to answer with a plan, not just a link to one, since an agent consuming this has no viewer.
Related
Column statistics (#filed separately) is the companion: a plan explains what the planner did, pg_stats explains why it thought that was a good idea. Neither is much use alone for a bad-estimate problem.
Sources consulted: PostgreSQL Wiki — Monitoring, Datadog — Advanced Configuration for Postgres DBM.
Part of the PostgreSQL parity effort (#2530). This is the largest single gap and probably wants breaking down further before anyone starts.
The gap
For SQL Server we have a whole plan family:
analyze_query_plan,analyze_procedure_plan,analyze_query_store_plan,analyze_plan_xml,get_plan_xml, the graphical plan viewer, plan-cache bloat reads, plan corrections. For PostgreSQL we capture no plans at all —git grepforauto_explain,EXPLAIN (,pg_stat_plansacross the collectors and service returns nothing, anddocs/uat-onboarding.mdalready admits it: "no plan capture or blocking-chain read" for pg targets.Datadog DBM captures explain plans for Postgres via sampling, and plans are the reason people open a database monitoring tool at all. Someone evaluating us against DBM on Aurora reaches this within the first hour.
What already exists to build on
PgStatementStatsCollectoralready collectspg_stat_statements(andaurora_stat_statements()on Aurora), so the query side is there — queryid, calls, timing. What is missing is the plan for a given queryid.The mechanisms, which need a decision
auto_explain— logs plans for statements over a duration threshold. Needs a shared-library preload and carries a per-statement cost; on RDS/Aurora it is a parameter-group change, not something the monitoring tool can switch on for itself.pg_stat_plans/ similar extensions — record plans alongside statements, but extension availability on managed Postgres is the constraint.EXPLAIN— the tool runsEXPLAINfor a query it has already seen. No preload needed, but the plan is now, not the plan from when it was slow, and parameters have to come from somewhere.The third is the only one that works with no server-side configuration, and it is also the weakest evidence. That trade is the substance of this issue.
Constraints worth naming up front
shared_preload_librariesto parameter groups and a restart, so anything requiring a preload is a customer action we can detect and advise on, not something we can arrange.Related
Column statistics (#filed separately) is the companion: a plan explains what the planner did,
pg_statsexplains why it thought that was a good idea. Neither is much use alone for a bad-estimate problem.Sources consulted: PostgreSQL Wiki — Monitoring, Datadog — Advanced Configuration for Postgres DBM.