Advertisement
GLASHATAY_007

Kill session

May 26th, 2023
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Select  -- pg_cancel_backend(pid),
  2.        -- pg_terminate_backend(pid),
  3.        pid,
  4.        datname As database,
  5.        usename As username,
  6.        -- regexp_replace(text(client_addr),'/.*','')||':'||client_port As address,
  7.        client_addr As address,
  8.        application_name As application,
  9.        state,
  10.        concat(wait_event,' ('||wait_event_type||')') As wait,
  11.        to_char(query_start,'dd.mm.yyyy hh24:mi:ss') As start,
  12.        cast(extract(epoch from (clock_timestamp()-query_start)) As numeric(18,3)) As duration,
  13.        translate(query,chr(7)||chr(10)||chr(13),'   ') As query
  14. From pg_stat_activity
  15. Where pid<>pg_backend_pid() And
  16.       -- client_addr='81.24.120.102' And
  17.       -- client_addr='192.168.90.35' And
  18.       -- client_addr='192.168.33.138' And
  19.       -- client_addr In ('192.168.90.35','192.168.33.138') And
  20.       -- client_addr='172.17.4.201' And
  21.       state='active' And     -- pid=34414 and
  22.       -- state Like 'idle in transaction%' And
  23.       -- coalesce(application_name,'')<>'Navicat' And
  24.             -- coalesce(application_name,'') Not Like 'pgAdmin%' And
  25.       -- coalesce(application_name,'')='PostgreSQL JDBC Driver' And
  26.       -- usename='gpospb' And
  27.       -- usename='pentaho' And
  28.       -- datname='pentaho' And
  29.       -- datname='contest' And
  30.             -- lower(query) Like '%select %stat%' And
  31.             -- lower(query) Like '%select %lot%' And
  32.       true ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement