Skip to content

Instantly share code, notes, and snippets.

@jeffersonsouza
Created August 30, 2018 22:40
Show Gist options
  • Save jeffersonsouza/8cfbef0d04c3ea51feae14300d6a6008 to your computer and use it in GitHub Desktop.
Save jeffersonsouza/8cfbef0d04c3ea51feae14300d6a6008 to your computer and use it in GitHub Desktop.

Revisions

  1. jeffersonsouza created this gist Aug 30, 2018.
    7 changes: 7 additions & 0 deletions PostgresUseful.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    -- Get active queries with duration greater than 1 sec
    SELECT (now() - query_start) as duracao, pid, query, usename, datname
    FROM pg_stat_activity
    WHERE state = 'active'
    AND query_start < now() - '1 seconds'::interval
    AND pid <> pg_backend_pid()
    ORDER BY query_start ASC