Re: Limit transaction lifetime - Mailing list pgsql-general

From Andrei Zhidenkov
Subject Re: Limit transaction lifetime
Date
Msg-id ED3B8A6F-1F2B-4833-B34E-5D99A050D9A6@n26.com
Whole thread Raw
In response to Re: Limit transaction lifetime  (Fabio Ugo Venchiarutti <f.venchiarutti@ocado.com>)
Responses Re: Limit transaction lifetime  (Fabio Ugo Venchiarutti <f.venchiarutti@ocado.com>)
List pgsql-general
> If it's a single command you're trying to limit `SET statement_timeout TO <whatever>` should do the trick.

This will set only statement timeout but won’t work for long transactions that contain a lot of short statements.

> If you want it based on the session's cumulative statement time, off the top of my head I can't think of anything in
vanillaPG without using executor hooks (that requires some coding). 

Yes, that’s exactly I want to do.

> If the queries that worry you are long-lived, you might be able to get by with a scheduled process checking against
pg_stat_activity(eg: age(query_start)) and adding the current query's run-time to some per-session total, but it's an
highlyinaccurate process. 

I think in my case I should check `xact_start`, because not every query initiates a new transaction.




pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: What do null column values for pg_stat_progress_vacuum mean?
Next
From: Fabio Ugo Venchiarutti
Date:
Subject: Re: Limit transaction lifetime