From: | Andrei Zhidenkov <andrei(dot)zhidenkov(at)n26(dot)com> |
---|---|
To: | f(dot)venchiarutti(at)ocado(dot)com |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Limit transaction lifetime |
Date: | 2020-03-06 16:14:59 |
Message-ID: | ED3B8A6F-1F2B-4833-B34E-5D99A050D9A6@n26.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 vanilla PG 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 highly inaccurate process.
I think in my case I should check `xact_start`, because not every query initiates a new transaction.
From | Date | Subject | |
---|---|---|---|
Next Message | Fabio Ugo Venchiarutti | 2020-03-06 16:18:53 | Re: Limit transaction lifetime |
Previous Message | Adrian Klaver | 2020-03-06 16:09:30 | Re: What do null column values for pg_stat_progress_vacuum mean? |