pgtoolkit/pgstats.py
changeset 44 4fe39c59c515
parent 39 0cef3540b69f
equal deleted inserted replaced
43:a921669e913a 44:4fe39c59c515
    39             return [dict(zip([desc[0] for desc in curs.description], row)) for row in rows]
    39             return [dict(zip([desc[0] for desc in curs.description], row)) for row in rows]
    40         finally:
    40         finally:
    41             curs.close()
    41             curs.close()
    42 
    42 
    43     def list_long_queries(self, longer_than='1m'):
    43     def list_long_queries(self, longer_than='1m'):
    44         return self._query('''SELECT datname, procpid, usename, current_query AS query,
    44         return self._query('''SELECT
    45             waiting, xact_start, query_start, backend_start
    45               datname, procpid, usename, current_query AS query,
       
    46               waiting, xact_start, query_start, backend_start, client_addr
    46             FROM pg_stat_activity
    47             FROM pg_stat_activity
    47             WHERE current_query <> '<IDLE>' AND query_start < now() - interval %s
    48             WHERE current_query <> '<IDLE>' AND query_start < now() - interval %s
    48             ORDER BY query_start;''',
    49             ORDER BY query_start;''',
    49             longer_than)
    50             longer_than)
    50 
    51