aurora_stat_plans
为每个跟踪的执行计划返回一行。
语法
aurora_stat_plans(
showtext
)
参数
showtext:显示查询和计划文本。有效值为 NULL、true 或 false。True 将显示查询和计划文本。
返回类型
为每个跟踪的计划返回一行,其中包含来自 aurora_stat_statements
的所有列和以下附加列。
planid:计划标识符
explain_plan:解释计划文本
plan_type:
no plan
:未捕获到任何计划estimate
:使用估计成本捕获的计划actual
:使用 EXPLAIN ANALYZE 捕获的计划
plan_captured_time:上次捕获计划的时间
使用说明
必须启用 aurora_compute_plan_id
并且 pg_stat_statements
必须处于 shared_preload_libraries
状态才能跟踪计划。
可用计划的数量由在 pg_stat_statements.max
参数中设置的值控制。启用 aurora_compute_plan_id
后,您可以在 aurora_stat_plans
中跟踪不超过此指定值的计划。
Aurora PostgreSQL 版本 14.10、15.5 以及所有其它更高版本都提供了此函数。
示例
在下面的示例中,将捕获用于查询标识符 5471422286312252535 的两个计划,并通过 planid 跟踪语句统计数据。
db1=# select calls, total_exec_time, planid, plan_captured_time, explain_plan db1-# from aurora_stat_plans(true) db1-# where queryid = '-5471422286312252535'
calls | total_exec_time | planid | plan_captured_time | explain_plan ---------+--------------------+-------------+-------------------------------+------------------------------------------------------------------ 1532632 | 3209846.097107853 | 1602979607 | 2023-10-31 03:27:16.925497+00 | Update on pgbench_branches + | | | | -> Bitmap Heap Scan on pgbench_branches + | | | | Recheck Cond: (bid = 76) + | | | | -> Bitmap Index Scan on pgbench_branches_pkey + | | | | Index Cond: (bid = 76) 61365 | 124078.18012200127 | -2054628807 | 2023-10-31 03:20:09.85429+00 | Update on pgbench_branches + | | | | -> Index Scan using pgbench_branches_pkey on pgbench_branches+ | | | | Index Cond: (bid = 17)