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 1vHMq4-0052vD-He for pgsql-general@arkaria.postgresql.org; Fri, 07 Nov 2025 13:49:16 +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 1vHMq3-00EKPn-8Q for pgsql-general@arkaria.postgresql.org; Fri, 07 Nov 2025 13:49:15 +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 1vHMq2-00EKOe-Su for pgsql-general@lists.postgresql.org; Fri, 07 Nov 2025 13:49:14 +0000 Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vHMpz-005uZt-2e for pgsql-general@postgresql.org; Fri, 07 Nov 2025 13:49:14 +0000 Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-5943d1d6471so830702e87.0 for ; Fri, 07 Nov 2025 05:49:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762523350; x=1763128150; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=Da1A/HqrxqYRZXmDxY0aqiOzSlnc2/IzmhbtsMiwcI8=; b=afJwDun2+3ypoWHBRG9d4rMcAVp+4Y+nOSHGoiP08R6oWV+OMVSAS/4RJXmTBJWe40 nU+miNltaL4AP+2bBxI8D0+J60ZRrOzOf3MrCuSWY1h6MeGLY+abNhjOqcj6NQtro3tZ lULuHasybrO55HSyaJETCu49P+x6AFezoezGDRcn7qCMMk3OE+i+U+lRN35VEHfMc88g vx1TQOoWOL///WKWMnZR3gRKdxXuRsLv3/Ymy9WHZOStw03LfmeOC622CSmhx+39yRtF zAq4Ruu7UYv2FxSqj85+2je3RinVKTw6qzxzrzt52aOSD8LHZES6kTJvmFtA6iX3vR/J CZoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762523350; x=1763128150; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Da1A/HqrxqYRZXmDxY0aqiOzSlnc2/IzmhbtsMiwcI8=; b=N6v/YoNWakOE9W+hd4tHm9TUfz20DMy6Z0Qu3EKEPhhy0Q6iIGYRTLOftMku4Laqfc uGugyIPce++q5FTjv9T09TWFBgxxrQ/dNdbPVeKQpY03YrrVdbLM7LikBA0RRbe9Ko0g KhP8JelTgJcgJOUku/uTkKNO8wWw4UnyOMsO0HXmhYKPkAthtjanMEMBkQob7sD6gUjc 6mwkWJxTmUA4upQ5CTQk1maZipvmwpkpeDG8GKtHR4X2mP0QaGCzl5ZgC0M/QAU4baC8 uD4uacwXS2RE0PWIN1gWQDFY2atdYvf0+ha6D5fI6y7NX94zLt9MVfJACXX5BhBeHv1y mCdg== X-Gm-Message-State: AOJu0YweTXVvzbs7UwsbymIWVKHi4Rfuo4j5Wn3B1mj3SfSyUG/Gj6YC 52sy43LSDKdrYfgNG1iWxEYlMoFI93Vv35z21byh3JlWFRibWpOUGw3xQBQSP0UtKp8C9GPqocS KoqmIpFgbAogvrN3dl0R+AesiQHxNjSqLnNj0ViQ= X-Gm-Gg: ASbGnctLdn9QWdqGLofJYKqX42IrsKzYimX/3UBOc6CvAUmHlLdGI0TrfiJkC47x09e 291oErBsMzllvna22F1V16UsNK1r9Rh0W/V0Do86pOHmGMxeSVhow7v1JueIhWwuRRXaowpPl5D 2E0q1Vvtwxxdcn6ne/7ZpwgH7ley1QsYBStBxrMV6i3dypLrGOV2C1jrzlgGU/9ojjN816EvHM9 YaiPXMGw7SqJN4bYOSiey1anSA9Pzgh7zNsaSmO2bKjQbS8bGOrl2At4u1kTxA1snnwHg== X-Google-Smtp-Source: AGHT+IFBKkw7/r+S6lIu3z6m0pxvthRE4GZmTdp2v3Y8zMR68HmbbvjsUFSDe+uKFijQzszv41xGSVYe06LYcUeJbr8= X-Received: by 2002:a05:6512:31ce:b0:594:4b7f:f947 with SMTP id 2adb3069b0e04-59456b4c9b5mr961720e87.18.1762523349356; Fri, 07 Nov 2025 05:49:09 -0800 (PST) MIME-Version: 1.0 From: Ashish Mukherjee Date: Fri, 7 Nov 2025 19:18:57 +0530 X-Gm-Features: AWmQ_bnvV_veh6nOSsczCeHjAPoQ3S4CQraELVIUqYCyS2O0A3ynVO26MNxLhSs Message-ID: Subject: Enquiry about long-running queries To: pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary="000000000000259757064301720b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000259757064301720b Content-Type: text/plain; charset="UTF-8" Hello, I have a query like this showing up on my production database - s05=> SELECT pid, user, usename, application_name, client_addr, client_hostname, client_port, datname, now() - query_start as "runtime", state, wait_event_type, wait_event, substr(query, 0, 100) FROM pg_stat_activity WHERE now() - query_start > '5 minutes'::interval and state = 'active' ORDER BY runtime DESC; pid | user | usename | application_name | client_addr | client_hostname | client_port | datname | runtime | state | wait_event_type | wait_event | substr -------+--------+-----------------+----------------+-------------------------------------------------------------------- 356274 | s05 | s05 | scandir | 192.168.64.61 | | 44098 | s05 | 9 days 18:45:37 .65577 | active | IPC | ParallelFinish | select scac_code from scac where supported_by_smc = true The query when run from psql prompt finishes in a jiffy, so query performance/cost is not the problem. Also, when I try to kill the query through pg_terminate_backend or pg_cancel_backend, it does not get killed. I am wondering what could be the root cause of this problem and how it could be addressed. Any pointers would be appreciated. Regards, Ashish --000000000000259757064301720b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello,

I have a query like this showing= up on my production database -=C2=A0

s05=3D> SEL= ECT pid, user, usename, application_name, client_addr, client_hostname, cli= ent_port, datname, now() - query_start as "runtime",
state, wa= it_event_type, wait_event,
substr(query, 0, 100)
=C2=A0FROM =C2=A0pg_= stat_activity
=C2=A0WHERE now() - query_start > '5 minutes'::= interval and state =3D 'active'
=C2=A0ORDER BY runtime DESC;
= =C2=A0 =C2=A0pid =C2=A0 | user | usename | application_name | =C2=A0client_= addr =C2=A0| client_hostname | client_port | datname | =C2=A0 =C2=A0 =C2=A0= =C2=A0runtime
=C2=A0 =C2=A0 =C2=A0 =C2=A0| state =C2=A0| wait_event_typ= e | =C2=A0 wait_event =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 substr
-------+--------+--= ---------------+----------------+------------------------------------------= --------------------------
=C2=A0 356274 | s05 =C2=A0| s05 =C2=A0 =C2=A0= | scandir =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| 192.168.64.61 | =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 44098 = | s05 =C2=A0 =C2=A0 | 9 days 18:45:37
.65577 | active | IPC =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | ParallelFinish | select scac_code from sc= ac where supported_by_smc =3D true

The query when = run from psql prompt finishes in a jiffy, so query performance/cost is not = the problem. Also, when I try to kill the query through pg_terminate_backen= d or pg_cancel_backend, it does not get killed.

I am wondering what = could be the root cause of this problem and how it could be addressed.=C2= =A0 Any pointers would be appreciated.

Regards,
Ashish
--000000000000259757064301720b--