LoginSignup
2
0

A5のタイムアウト設定により、canceling statement due to statement timeout

Posted at

課題

A5-Mk2で、PostgreSQLをさわっていたら、タイムアウトエラーが発生した。

実行結果
canceling statement due to statement timeout

実行したクエリは下記である。

実行クエリ
delete from articles where article_id between 11183 and 12631 and article_url like 'https://www.eo%' and remarks = 'クエリテスト'

article_idは主キーであり、したがってINDEXが張られているため高速に実行できると期待したがこちらも同様にタイムアウトになった。

実行クエリ
delete from articles where article_id between 11183 and 12631;

なお参考として、articlesテーブルの総件数は15494件、バイト数はおよそ17メガバイトという状況である。

実行クエリ
SELECT
    relname as table_name
    , reltuples as row_num
    , (relpages * 8192) as byte_size 
FROM
    pg_class 
WHERE
    relname = 'articles';
実行結果
table_name	row_num	byte_size
articles	15459	17924096

タイムアウト設定を確認

タイムアウト値は、30秒である。実際に計ってみると、確かに30秒経過したタイミングで上記のエラーになる。

実行クエリ
SHOW statement_timeout;
実行結果
30s

postgresql.confのstatement_timeoutを確認すると

#statement_timeout = 0

このようにコメントアウトされている。(特に設定をいじっていないので、PostgreSQL14の初期値である。)

初期値の場合、タイムアウトは無制限であるが、今回の場合、A5-Mk2の設定で、タイムアウト値が30秒に設定されている。

(コマンドプロンプトでSHOW statement_timeout;としてみれば、0と出る)

A5上で、

set statement_timeout to 60000;

としても、A5の設定の方が優先されてしまい、変更することはできない。

対応

A5-Mk2のタイムアウト値を延伸する。

image.png

60秒に延伸したところ、成功した。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0