Skip to content

Instantly share code, notes, and snippets.

@ugursogukpinar
Created April 4, 2019 11:32
Show Gist options
  • Save ugursogukpinar/127f86868024d13e13469cb53b868972 to your computer and use it in GitHub Desktop.
Save ugursogukpinar/127f86868024d13e13469cb53b868972 to your computer and use it in GitHub Desktop.
PostgreSQL get transaction durations
SELECT *, now() - xact_start as duration FROM pg_stat_activity WHERE state IN ('idle in transaction', 'active')
order by now() - xact_start desc
limit 5;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment