PostgreSQL – Terminate Client Connect View

Table of Contents

PostgreSQL - Terminate Client Connect View

To fix 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
 SELECT pg_terminate_backend( AS pg_terminate_backend
   FROM pg_stat_activity
  WHERE <> pg_backend_pid() AND pg_stat_activity.datname = 'database_name'::name;

ALTER TABLE public.terminate_client_connect
    OWNER TO postgres;

Leave a Reply

Your email address will not be published. Required fields are marked *