Table of Contents
PostgreSQL - Terminate Client Connect View
To fix
FATAL: sorry, too many clients already connection to server
https://dothanhlong.org/postgresql-fatal-sorry-too-many-clients-already-connection-to-server/
-- View: public.terminate_client_connect
-- DROP VIEW public.terminate_client_connect;
CREATE OR REPLACE VIEW public.terminate_client_connect
AS
SELECT pg_terminate_backend(pg_stat_activity.pid) AS pg_terminate_backend
FROM pg_stat_activity
WHERE pg_stat_activity.pid <> pg_backend_pid() AND pg_stat_activity.datname = 'database_name'::name;
ALTER TABLE public.terminate_client_connect
OWNER TO postgres;