1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

はじめに

業務でタイムアウトエラー時の処理を実装する際にデバッグとして使用したので、そのメモです。

実行環境

  • Windows 10 Pro 22H2
  • psql (PostgreSQL) 16.1

本文

select pg_sleep(n);
  • n: integer型
  • 単位: 秒

例)

select pg_sleep(60);
// 60秒スリープさせる

他にも以下のような関数が実装されている。

pg_sleep_for ( interval );
pg_sleep_until ( timestamp with time zone );

例)

SELECT pg_sleep_for('5 minutes');
SELECT pg_sleep_until('tomorrow 03:00');

おわりに

特記するべき事項はないが、テストやデバッグの際に覚えておくと便利なので、頭の片隅にでも置いておくのがいいと思います。

参考文献

PostgreSQL 15.4文書 9.9.6. 遅延実行

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?