> 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.