0

I have to set the query timeout for Postgres database to 60 mins. I have below configuration files for the Postgres database.

  1. pg_ctl.conf
  2. pg_hba.conf
  3. pg_ident.conf
  4. postgresql.conf
  5. start.conf

In the postgresql.conf file, I see there are fields;

#statement_timeout = 0      # in milliseconds, 0 is disabled
#lock_timeout = 0           # in milliseconds, 0 is disabled

My question is, Which field I need to uncomment/set for 60 mins?

Does somebody please help on this? Or Do I need to add something else in the configuration file?

Thanks in advance.

1
  • Unrelated to your question, but: Unrelated to your problem, but: Postgres 9.1 is no longer supported you should plan an upgrade as soon as possible. Commented Sep 17, 2020 at 8:52

1 Answer 1

2

To set a global default for a query time out, use statement_timeout, e.g.

statement_timeout = 60min

Quote from the manual

Abort any statement that takes more than the specified amount of time. [...] If this value is specified without units, it is taken as milliseconds. A value of zero (the default) disables the timeout.
The timeout is measured from the time a command arrives at the server until it is completed by the server.

If you only want to do this for a specific user, it's not necessary to do it globally (for every user):

alter user the_user_to_control 
    set statement_timeout = '60min';

That will change the value for the specified user in the current database. If you really need it in every database, you will need to run that statement statement in every database.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.