Set timeout just on a query?

Started by Shaozhong SHIalmost 4 years ago4 messagesgeneral
Jump to latest
#1Shaozhong SHI
shishaozhong@gmail.com

Can timeout be set just on a query?

Can we do the following?

Begin

do a query
set timeout
Exception
report a record

End;

Regards,
David

#2Shaozhong SHI
shishaozhong@gmail.com
In reply to: Shaozhong SHI (#1)

Can timeout be set just on a query?

Can we do the following?

Begin

do a query
set timeout
Exception
report a record

End;

Regards,
David

#3Christophe Pettus
xof@thebuild.com
In reply to: Shaozhong SHI (#1)
Re: Set timeout just on a query?

On May 9, 2022, at 17:58, Shaozhong SHI <shishaozhong@gmail.com> wrote:
Begin

do a query
set timeout
Exception
report a record

End;

Yes. The syntax you are looking for is:

SET LOCAL statement_timeout = '<value>';

Best,
-- Christophe

#4Bharath Rupireddy
bharath.rupireddyforpostgres@gmail.com
In reply to: Shaozhong SHI (#2)
Re: Set timeout just on a query?

On Tue, May 10, 2022 at 6:29 AM Shaozhong SHI <shishaozhong@gmail.com> wrote:

Can timeout be set just on a query?

Can we do the following?

Begin

do a query
set timeout
Exception
report a record

End;

Won't the statement_timeout [1]https://www.postgresql.org/docs/devel/runtime-config-client.html help here?

[1]: https://www.postgresql.org/docs/devel/runtime-config-client.html

Regards,
Bharath Rupireddy.