-1

I'm running a cron job using pg_cron.

The job is running some cleanup queries, that occasionally takes longer to complete.

When that happens, the job fails on statement timeout of 2 min which is the default

ERROR: canceling statement due to statement timeout

I'd like to increase the statement_timeout for this job.

set statement_timeout='1200s'
select do_cleanup_tasks()

What would be the scope of this statement timeout change? Will it effect only the execution of this transaction, or it has a wider effect?

1 Answers1

0

That will give you an opposite effect. The statement_timeout is by default zero, and means "no timeout". But if you set in your query - then it will affect all statements in this session (until disconnect).

If you want to increase timeout - first look at the tool you using to run the queries and how it connects to the server. This is the most likely source of timeout.

Also look at global server's setting (statement_timeout in postgresql.conf). If it is zero - then return to the client tool and its connection settings.

White Owl
  • 1,029
  • 3
  • 9