Skip to content

Instantly share code, notes, and snippets.

@mrtrom
Created February 28, 2017 22:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrtrom/deb2a0b3c711ef730340f4f878ea91d6 to your computer and use it in GitHub Desktop.
Save mrtrom/deb2a0b3c711ef730340f4f878ea91d6 to your computer and use it in GitHub Desktop.
PostgreSQL useful commands
--Check activity tracker
SELECT *
FROM pg_stat_activity
--Check activity tracker by query time
SELECT
(CURRENT_TIMESTAMP - query_start) as query_time
, *
-- ^^ SQL protip: separating SELECT parameters by linebreaks and putting the
-- comma first lets you quickly comment out single parameters
FROM pg_stat_activity
ORDER BY query_time DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment