aurora_stat_plans - Amazon Aurora

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

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)