Обсуждение: Statement timeout

Поиск
Список
Период
Сортировка

Statement timeout

От
Edson Richter
Дата:
I've set statement timeout in postgresql.conf to 300s.
Now, I have a schema update procedure at application startup I would
like to run without timeout, or with significant larger timeout (let's
say, 10000s).

It is possible to change statement timeout at runtime before issuing the
command (for one connection only) without changing postgresql.conf?

I'm using JDBC, and I've imagined something like


java.sql.Connection cn = getConnection(); // this is a function that
returns a connection form the connection's pool.
java.sql.Statement st = cn.createStatement();
cn.setAutoCommit(false);
st.executeQuery("set statement_timeout = 10000s");
st.executeUpdate("update table XYZ set value_non_zero = 1 where
value_non_zero is null or value_non_zero = 0");
st.executeUpdate("alter table XYZ modify value_non_zero not null default
1");
cn.commit();

Something like that (I know sql syntax is wrong, this is just a lazy
example)...

--
Atenciosamente,

Edson Carlos Ericksson Richter



Re: Statement timeout

От
"Joshua D. Drake"
Дата:
On 01/29/2016 07:00 AM, Edson Richter wrote:
> I've set statement timeout in postgresql.conf to 300s.
> Now, I have a schema update procedure at application startup I would
> like to run without timeout, or with significant larger timeout (let's
> say, 10000s).
>
> It is possible to change statement timeout at runtime before issuing the
> command (for one connection only) without changing postgresql.conf?

Yes, use SET

SET statement_timeout TO '$duration';

JD



--
Command Prompt, Inc.                  http://the.postgres.company/
                      +1-503-667-4564
PostgreSQL Centered full stack support, consulting and development.