Skip to content

Instantly share code, notes, and snippets.

@MichaelDBA
Created September 26, 2016 14:55
Show Gist options
  • Save MichaelDBA/5153e4e7e29bde5ff4e45eac22ed4a25 to your computer and use it in GitHub Desktop.
Save MichaelDBA/5153e4e7e29bde5ff4e45eac22ed4a25 to your computer and use it in GitHub Desktop.
blackjack_staging=# select now(), state, query_start, to_char( (round(extract(epoch from (now() - (query_start)))) || ' second')::interval, 'HH24:MI:SS') as duration, xact_start, query from pg_stat_activity where pid = 2349;
now | state | query_start | duration | xact_start | query
-------------------------------+--------+-------------------------------+----------+-------------------------------+-------------------------------------------------------------------------------------------------------------------------
2016-09-26 09:53:57.912076-05 | active | 2016-09-26 09:43:55.443251-05 | 00:10:02 | 2016-09-26 09:43:55.299271-05 | SELECT count(*) FROM pg_catalog.pg_class AS c WHERE c.oid = to_regclass('"user_capability"') AND c.relpersistence = 'u'
(1 row)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment