Skip to content

Instantly share code, notes, and snippets.

@scottmcclung
Forked from romuald/processlist.sql
Created July 12, 2024 15:46
Show Gist options
  • Select an option

  • Save scottmcclung/8eaa8e2cff865b3ae0f4ac97065b1e35 to your computer and use it in GitHub Desktop.

Select an option

Save scottmcclung/8eaa8e2cff865b3ae0f4ac97065b1e35 to your computer and use it in GitHub Desktop.

Revisions

  1. @romuald romuald revised this gist Oct 3, 2016. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions processlist.sql
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,5 @@
    SELECT
    datname, procpid, usename, current_query, waiting, xact_start, query_start, client_addr, NOW() - query_start AS elapsed
    SELECT user, pid, client_addr, waiting, query, query_start, NOW() - query_start AS elapsed
    FROM pg_stat_activity
    WHERE current_query != '<IDLE>'
    WHERE query != '<IDLE>'
    -- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1
    ORDER BY elapsed DESC;
  2. @romuald romuald revised this gist Aug 26, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion processlist.sql
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,4 @@ SELECT
    FROM pg_stat_activity
    WHERE current_query != '<IDLE>'
    -- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1
    ORDER elapsed DESC;
    ORDER BY elapsed DESC;
  3. @romuald romuald created this gist Aug 24, 2016.
    6 changes: 6 additions & 0 deletions processlist.sql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    SELECT
    datname, procpid, usename, current_query, waiting, xact_start, query_start, client_addr, NOW() - query_start AS elapsed
    FROM pg_stat_activity
    WHERE current_query != '<IDLE>'
    -- AND EXTRACT(EPOCH FROM (NOW() - query_start)) > 1
    ORDER elapsed DESC;