背景 場景: 黑天鵝, 突發事件. 負載突然升高, 響應突然變慢. 挑戰: 已經發生的突發事件, 如何分析其原因? 哪裡有 資料、案例、邏輯 ? PG 解決方案: 性能洞察, 采樣點(平均活躍會話數、等待事件、SQL細粒度) stats 統計快照 auto_explain, 設定門檻值, 超出記錄執行和消耗詳情. 鎖等待日志記錄. https://github.com/digoal/blog/blob/master/202106/20210621_03.md#%E5%8F%82%E8%80%83 參考 《PostgreSQL pg_stat_statements AWR 插件 pg_stat_monitor , 過去任何時間段性能分析 [推薦、收藏]》 《PostgreSQL 函數調試、診斷、優化 & auto_explain & plprofiler》 《PostgreSQL Oracle 相容性之 - performance insight - AWS performance insight 理念與實作解讀 - 珍藏級》 https://www.postgresql.org/docs/14/auto-explain.html https://www.postgresql.org/docs/devel/runtime-config-locks.html