Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ln0Jg-00086r-Aw for pgsql-admin@arkaria.postgresql.org; Sat, 29 May 2021 14:51:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ln0Jf-0000b5-An for pgsql-admin@arkaria.postgresql.org; Sat, 29 May 2021 14:51:55 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ln0Jf-0000ax-25 for pgsql-admin@lists.postgresql.org; Sat, 29 May 2021 14:51:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ln0JY-0008Hj-Sm for pgsql-admin@lists.postgresql.org; Sat, 29 May 2021 14:51:54 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 14TEp4r92045347; Sat, 29 May 2021 10:51:04 -0400 From: Tom Lane To: dave@davebolt.co.uk cc: "'Julien Rouhaud'" , mustafa.pekgoz@forenda.com.tr, "'Pgsql-admin'" Subject: Re: equivalent of @@TRANCOUNT PostgreSQL In-reply-to: <042901d75497$c2da72d0$488f5870$@co.uk> References: <004101d7548b$894e0ce0$9bea26a0$@forenda.com.tr> <042901d75497$c2da72d0$488f5870$@co.uk> Comments: In-reply-to message dated "Sat, 29 May 2021 15:34:41 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2045345.1622299864.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 29 May 2021 10:51:04 -0400 Message-ID: <2045346.1622299864@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk writes: > @@TRANCOUNT: Transaction count. > How many transactions are open at the moment. > I=E2=80=99m not seeing anything that looks appropriate. As far as I can = see it might be possible to do something using the Statistics Collector, s= ee https://www.postgresql.org/docs/13/monitoring-stats.html Yeah, something like this should do for that: select count(*) from pg_stat_activity where state is not null; regards, tom lane