public inbox for [email protected]
help / color / mirror / Atom feedFrom: Murthy Nunna <[email protected]>
To: [email protected] <[email protected]>
Subject: psql help
Date: Thu, 4 Jul 2024 23:56:03 +0000
Message-ID: <DM8PR09MB6677C5B4FDBDFC0F82298DC7B8DE2@DM8PR09MB6677.namprd09.prod.outlook.com> (raw)
Hello:
Following works-
SELECT pid, pg_terminate_backend(pid) FROM pg_stat_activity
WHERE pid IN (select unnest(pg_blocking_pids(pid)) from pg_stat_activity where cardinality(pg_blocking_pids(pid)) > 0)
and usename = 'DBUSER_10'
and now() - state_change >= interval $a'${TIMEOUT_MINS}'$a
order by now() - state_change >= interval $a'${TIMEOUT_MINS}'$a desc limit 1;
How can I rewrite the above in psql and pg_terminate_backend all pids that meet above criteria (essentially remove limit 1) ?
Thanks!
Note:
I run this in Linux. TIMEOUT_MINS is env variable.
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: psql help
In-Reply-To: <DM8PR09MB6677C5B4FDBDFC0F82298DC7B8DE2@DM8PR09MB6677.namprd09.prod.outlook.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox