Re: setting query timeout as part of the query - Mailing list pgsql-novice

From Tom Lane
Subject Re: setting query timeout as part of the query
Date
Msg-id 20756.1412110415@sss.pgh.pa.us
Whole thread Raw
In response to Re: setting query timeout as part of the query  (Steve Crawford <scrawford@pinpointresearch.com>)
Responses Re: setting query timeout as part of the query  (William Morgan <william@introhq.com>)
Re: setting query timeout as part of the query  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-novice
Steve Crawford <scrawford@pinpointresearch.com> writes:
> On 09/30/2014 12:52 PM, William Morgan wrote:
>> My question is: is there a way to set this timeout as part of the
>> query itself?

> You could probably write a function that includes your timeout setting
> and call that but I'm not sure that would be better than simply using a
> transaction.

IIRC, statement_timeout applies to the total time required to execute
a *command submitted by the client*, and the active value is determined
just before starting each command.  So you're pretty much stuck: you
must issue the SET as a separate client-submitted command.

As Steve says, it should be possible to ensure that the pooler doesn't
take the session away from you in between, by wrapping the whole thing
in BEGIN/COMMIT if nothing else.  If the pooler will take away a session
intra-transaction, it is 100% broken and dangerous, and you need to get
another one.

            regards, tom lane


pgsql-novice by date:

Previous
From: Steve Crawford
Date:
Subject: Re: setting query timeout as part of the query
Next
From: William Morgan
Date:
Subject: Re: setting query timeout as part of the query