root/trunk/curo/s/activity/query.1.sql

Revision 281, 0.8 kB (checked in by depesz, 3 years ago)

show data only about current database

Line 
1 SELECT
2     lpad(
3         to_char(
4             extract(
5                 epoch FROM clock_timestamp()-xact_start
6             ),
7             'FM999999990.000"s"'
8         ),
9         10
10     ) as xact_t,
11     lpad(
12         to_char(
13             extract(
14                 epoch FROM clock_timestamp()-query_start
15             ),
16             'FM999999990.000"s"'
17         ),
18         10
19     ) as query_t,
20     case when waiting then 'LOCK'::text else '    '::text end as lock,
21     coalesce( client_addr::TEXT, '[local]') || ':' || client_port as client,
22     array_to_string(
23         ARRAY( SELECT (regexp_matches( current_query, '(.{1,80})', 'g'))[1] ),
24         E' --\n'
25     ) as query
26 FROM
27     pg_stat_activity
28 WHERE
29     current_query <> '<IDLE>'
30     AND procpid <> pg_backend_pid()
31     AND datname = current_database()
32 ORDER BY
33     xact_start
34 ;
Note: See TracBrowser for help on using the browser.