pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Script timeout
4+ messages / 3 participants
[nested] [flat]

* Script timeout
@ 2013-09-17 16:23  Roberto Grandi <roberto.grandi@trovaprezzi.it>
  0 siblings, 2 replies; 4+ messages in thread

From: Roberto Grandi @ 2013-09-17 16:23 UTC (permalink / raw)
  To: pgsql-admin


Dear all,

i would set a script timeout from a .net application. My problem regards how to make sure that time out will be reset at the end of the script such as

SET statement_timeout 1000
SELECT pg_sleep(2);

trowhs exception


After that

SELECT pg_sleep(2);

wouldn't throw exception.


Can you help me to solve this issue?

Many thanks in advance.

BR
Roberto


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Script timeout
@ 2013-09-17 16:37  Federico <rotellaro@gmail.com>
  parent: Roberto Grandi <roberto.grandi@trovaprezzi.it>
  1 sibling, 1 reply; 4+ messages in thread

From: Federico @ 2013-09-17 16:37 UTC (permalink / raw)
  To: Roberto Grandi <roberto.grandi@trovaprezzi.it>; +Cc: pgsql-admin

This should work.
SELECT set_config('statement_timeout','1000 s',false);

The set_config function is quite flexible as can accept dynamic values.
More info here
http://www.postgresql.org/docs/current/static/functions-admin.html

I've used successfully to change the script timeout for each statement in
my maintenance scripts using a temporary table to store the deadline.

Kind Regards
Federico


On 17 September 2013 17:23, Roberto Grandi <roberto.grandi@trovaprezzi.it>wrote:

>
> Dear all,
>
> i would set a script timeout from a .net application. My problem regards
> how to make sure that time out will be reset at the end of the script such
> as
>
> SET statement_timeout 1000
> SELECT pg_sleep(2);
>
> trowhs exception
>
>
> After that
>
> SELECT pg_sleep(2);
>
> wouldn't throw exception.
>
>
> Can you help me to solve this issue?
>
> Many thanks in advance.
>
> BR
> Roberto
>
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>



-- 
Federico Campoli
DE MATERIALIZING, UK, Planet Earth, The Milky Way Galaxy
/*******************************
There's no point being grown-up if you can't be childish sometimes.
(The fourth Doctor)
http://www.pgdba.co.uk
*******************************/

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Script timeout
@ 2013-09-17 17:52  Roberto Grandi <roberto.grandi@trovaprezzi.it>
  parent: Federico <rotellaro@gmail.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Roberto Grandi @ 2013-09-17 17:52 UTC (permalink / raw)
  To: Federico <rotellaro@gmail.com>; +Cc: pgsql-admin


Hi,

I think your suggestion is


SELECT set_config('statement_timeout','1000 s',false); -- enable timeout

--
-- DO SQL Statements here
--

SELECT set_config('statement_timeout','0',false); -- disable timeout


Am I correct? Moreover what can happen if another query runs on the same connection pool ?
I would limit the effect only on this specific query.


Roberto



----- Original Message -----
From: "Federico" <rotellaro@gmail.com>
To: "Roberto Grandi" <roberto.grandi@trovaprezzi.it>
Cc: pgsql-admin@postgresql.org
Sent: Tuesday, September 17, 2013 6:37:09 PM
Subject: Re: [ADMIN] Script timeout

This should work.
SELECT set_config('statement_timeout','1000 s',false);

The set_config function is quite flexible as can accept dynamic values.
More info here
http://www.postgresql.org/docs/current/static/functions-admin.html

I've used successfully to change the script timeout for each statement in
my maintenance scripts using a temporary table to store the deadline.

Kind Regards
Federico


On 17 September 2013 17:23, Roberto Grandi <roberto.grandi@trovaprezzi.it>wrote:

>
> Dear all,
>
> i would set a script timeout from a .net application. My problem regards
> how to make sure that time out will be reset at the end of the script such
> as
>
> SET statement_timeout 1000
> SELECT pg_sleep(2);
>
> trowhs exception
>
>
> After that
>
> SELECT pg_sleep(2);
>
> wouldn't throw exception.
>
>
> Can you help me to solve this issue?
>
> Many thanks in advance.
>
> BR
> Roberto
>
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>



-- 
Federico Campoli
DE MATERIALIZING, UK, Planet Earth, The Milky Way Galaxy
/*******************************
There's no point being grown-up if you can't be childish sometimes.
(The fourth Doctor)
http://www.pgdba.co.uk
*******************************/
Hi


-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Script timeout
@ 2013-09-23 14:32  Patrick KUI-LI <pkuili@hi-media.com>
  parent: Roberto Grandi <roberto.grandi@trovaprezzi.it>
  1 sibling, 0 replies; 4+ messages in thread

From: Patrick KUI-LI @ 2013-09-23 14:32 UTC (permalink / raw)
  To: Roberto Grandi <roberto.grandi@trovaprezzi.it>; pgsql-admin

Hi ,

When you don't specify unit, it's in ms.
See the test bellow:

BR
Patrick KUI-LI


postgres=# SET statement_timeout TO 1000;
SET
Time: 0.214 ms
postgres=# show statement_timeout;
 statement_timeout
-------------------
 1s
(1 row)

Example with unit:
postgres=# SET statement_timeout TO '1000s';
SET
Time: 0.229 ms
postgres=# SELECT pg_sleep(2);
 pg_sleep
----------
 
(1 row)

Time: 2001.566 ms
postgres=#




On 09/17/2013 06:23 PM, Roberto Grandi wrote:
> Dear all,
>
> i would set a script timeout from a .net application. My problem regards how to make sure that time out will be reset at the end of the script such as
>
> SET statement_timeout 1000
> SELECT pg_sleep(2);
>
> trowhs exception
>
>
> After that
>
> SELECT pg_sleep(2);
>
> wouldn't throw exception.
>
>
> Can you help me to solve this issue?
>
> Many thanks in advance.
>
> BR
> Roberto
>
>



-- 
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2013-09-23 14:32 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-09-17 16:23 Script timeout Roberto Grandi <roberto.grandi@trovaprezzi.it>
2013-09-17 16:37 ` Federico <rotellaro@gmail.com>
2013-09-17 17:52   ` Roberto Grandi <roberto.grandi@trovaprezzi.it>
2013-09-23 14:32 ` Patrick KUI-LI <pkuili@hi-media.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox