PostgreSQL , SQL逾時
設定單條SQL的執行逾時,防雪崩。
通常來說可以在SQL發起前設定事務級逾時參數,SQL執行結束,重置。(如果SQL異常退出,會自動重置事務級參數)
例如這個QUERY,我們想讓它100毫秒逾時。
将它寫到函數中,在函數中設定逾時
調用SQL改成這樣
但是這麼做實際上是沒有效果的,原因是statement_timeout的設計之初是為互動性SQL設計的,在postgres.c中。
是以需要plpgsql逾時,需要通過插件HOOK來實作。
<a href="https://www.postgresql.org/message-id/flat/200702201200.53535.xzilla%40users.sourceforge.net#[email protected]">https://www.postgresql.org/message-id/flat/200702201200.53535.xzilla%40users.sourceforge.net#[email protected]</a>
1、執行個體級
2、庫級
3、使用者級
4、會話級
5、事務級
6、函數級
1、空閑事務逾時
2、鎖等待逾時
3、死鎖檢測逾時間隔
<a href="https://www.postgresql.org/docs/9.4/static/runtime-config-client.html">https://www.postgresql.org/docs/9.4/static/runtime-config-client.html</a>