Skip to content

Instantly share code, notes, and snippets.

@scisco
Created May 13, 2016 15:29
Show Gist options
  • Select an option

  • Save scisco/879c9827912dd59c5ff2ee58ff6e87a6 to your computer and use it in GitHub Desktop.

Select an option

Save scisco/879c9827912dd59c5ff2ee58ff6e87a6 to your computer and use it in GitHub Desktop.

Revisions

  1. Scisco created this gist May 13, 2016.
    11 changes: 11 additions & 0 deletions postgres.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    ```
    SELECT
    pg_terminate_backend(pid)
    FROM
    pg_stat_activity
    WHERE
    -- don't kill my own connection!
    pid <> pg_backend_pid()
    -- don't kill the connections to other databases
    AND datname = 'databasename';
    ```