Packages
Ecto PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.
Current section
Files
Jump to
Current section
Files
lib/queries/kill_all.ex
defmodule EctoPSQLExtras.KillAll do
@behaviour EctoPSQLExtras
def info do
%{
title: "Kill all the active database connections",
columns: [
%{name: :killed, type: :boolean}
]
}
end
def query do
"""
/* ECTO_PSQL_EXTRAS: Kill all the active database connections */
SELECT pg_terminate_backend(pid) AS killed FROM pg_stat_activity
WHERE pid <> pg_backend_pid()
AND query <> '<insufficient privilege>'
AND datname = current_database();
"""
end
end