psql help - Mailing list pgsql-general

From Murthy Nunna
Subject psql help
Date
Msg-id DM8PR09MB6677C5B4FDBDFC0F82298DC7B8DE2@DM8PR09MB6677.namprd09.prod.outlook.com
Whole thread Raw
Responses Re: psql help
List pgsql-general

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.

 

 

 

pgsql-general by date:

Previous
From: Guyren Howe
Date:
Subject: Re: Design strategy for table with many attributes
Next
From: "David G. Johnston"
Date:
Subject: Re: JSONPath operator and escaping values in query