Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmhci-009Fyc-A2 for pgsql-general@arkaria.postgresql.org; Mon, 24 Feb 2025 23:12:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tmhch-00AYyN-8D for pgsql-general@arkaria.postgresql.org; Mon, 24 Feb 2025 23:12:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tmhcg-00AYyF-MZ for pgsql-general@lists.postgresql.org; Mon, 24 Feb 2025 23:12:26 +0000 Received: from mail-oo1-xc29.google.com ([2607:f8b0:4864:20::c29]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tmhcd-000Ym5-2N for pgsql-general@postgresql.org; Mon, 24 Feb 2025 23:12:25 +0000 Received: by mail-oo1-xc29.google.com with SMTP id 006d021491bc7-5f89aa7a101so1809613eaf.2 for ; Mon, 24 Feb 2025 15:12:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1740438744; x=1741043544; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=GAtcSSaxaiyUpaarfGk14yQUKis+XP3Ntd1ZhzOzxp4=; b=LskgXSV28JACs3pYCyAh+G03X9jOIVbvWOGvbPOJQkb9c4o7g9uG46Fghjd1O8MbsP PY2heFG9lgaZ0nW/DIvXqNglb/wZ+L20Dh0NdZ1KyK1DPNe/bLTdELgYiPO17UVvst/t hIFbjUa6tDaqjN1NOPUADxmIaWh++oMALTfDmhKv2S5xu7V59no0CrLOG7XoESEuO+RK d0gtigOfZdKrjBjH8Un+x6lwVPgyR+F9bYTfqvzYIVT6bGIKhVNKY/TYcMgnfw/+P7EY RiQbrgOocfjEk+mS/MBwRCijS1/7ne7gHquuPXVDI8RJBr2pjWFtczsU6HJX332CA83G gPXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740438744; x=1741043544; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GAtcSSaxaiyUpaarfGk14yQUKis+XP3Ntd1ZhzOzxp4=; b=qHZfy2x2MDN4XKHgxmOoanv6lMHSqoX6Z/Tx8memZu0YQuYDXSbyhIS3MMYBYhHW2D s8LR7sbYXbVrPgerngnSaWa58dIJ2oQKXdHqFnYpmat9eKvVkLBFK5RodOigX/enO2lR cIwrwaCdQYwKrmwyUEfbF94TzmBd5WRCdRS597IXy6G1nsIS4v1mSiXHy75lE12RC6ip CZ0Ctc/Sj/U5dGocX9uf1Sn5CuQlnOgHrB8REwCybnzuqluUv+KXfaKJ7LAzn4BPU/A9 hsfekVGabSTaNhmBu7I96YhW0RF2w+c5/pBFuYDQuxLROaoaSXGlgFGc9uChda9mdZBY 7c6w== X-Gm-Message-State: AOJu0Yw0G1LSHOtQMyNGmTZEjEOBI8nUozE5hOBJwJYlIra6rVjJdvqq GkhlX8STudz6jBnkG40r//qVpwbsCAQDqUjWbsbqvGV9qhpDSY2Bh+Y7p9AmMiDKQH0LLz9jAg0 wg3qxPvRy+0bIgMxDtD2b8IEJIzkx9mYm X-Gm-Gg: ASbGnctvqeIPLUIKf8RB6vZLhd1o10ecvGYB8Ji+x18aZei7fbH2a2SNedPlLzT6Wym 56fNcv5opqc2tORp3u5Va90O4TRi2UZoyX0LxaJorIvDdTxcno6HoyCNx99A6G+rgM9Camlscgt xGqNM3PzbyaC3VC65qnth1dgGktRGvss8CGwX9V6ZVbw== X-Google-Smtp-Source: AGHT+IFDRIBiiJXAi8s2PasjC301sLx3wUuAPKfMQP24WReKd35drjX4j6oAdW51JyHEN+uf3B30UzVm2ie2PAWZeiA= X-Received: by 2002:a05:6820:2d09:b0:5fc:f477:911c with SMTP id 006d021491bc7-5fe9370b9e8mr917456eaf.2.1740438743966; Mon, 24 Feb 2025 15:12:23 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Mon, 24 Feb 2025 18:12:13 -0500 X-Gm-Features: AWEUYZmvqM_wbTo-2hP-4ZKrkcHgsVhPqdCxrmSca01rrH82gVOFKRE_wN-9-VM Message-ID: Subject: Re: Deleting idle connections To: pgsql-general Content-Type: multipart/alternative; boundary="000000000000166c45062eeb7982" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000166c45062eeb7982 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Feb 24, 2025 at 5:50=E2=80=AFPM Yongye Serkfem = wrote: > Hi Everyone! > I am having a series of idle connections and unable to delete them with a > single command. Any help in realizing this would be greatly appreciated. > This will kill idle connections older than two hours: select pid, pg_terminate_backend(pid) from pg_stat_activity where state =3D 'idle' and (EXTRACT(epoch FROM now() - backend_start))/3600.0 > 2; Be warned that it might kill more than you want. Add more WHERE predicates as filter. --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --000000000000166c45062eeb7982 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable