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 1ln0Zf-0000Ja-O1 for pgsql-admin@arkaria.postgresql.org; Sat, 29 May 2021 15:08:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ln0Ze-0002Ac-Ck for pgsql-admin@arkaria.postgresql.org; Sat, 29 May 2021 15:08:26 +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 1ln0Ze-0002AT-45 for pgsql-admin@lists.postgresql.org; Sat, 29 May 2021 15:08:26 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ln0ZX-0008OU-QL for pgsql-admin@lists.postgresql.org; Sat, 29 May 2021 15:08:25 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1ln0ZU-0000rH-60; Sat, 29 May 2021 11:08:16 -0400 Date: Sat, 29 May 2021 11:08:16 -0400 From: Bruce Momjian To: dave@davebolt.co.uk Cc: 'Julien Rouhaud' , mustafa.pekgoz@forenda.com.tr, 'Pgsql-admin' Subject: Re: equivalent of @@TRANCOUNT PostgreSQL Message-ID: <20210529150816.GB23127@momjian.us> References: <004101d7548b$894e0ce0$9bea26a0$@forenda.com.tr> <042901d75497$c2da72d0$488f5870$@co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <042901d75497$c2da72d0$488f5870$@co.uk> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, May 29, 2021 at 03:34:41PM +0100, dave@davebolt.co.uk wrote: > @@TRANCOUNT: Transaction count. > > How many transactions are open at the moment. > > I’m not seeing anything that looks appropriate. As far as I can see it might be > possible to do something using the Statistics Collector, see https:// > www.postgresql.org/docs/13/monitoring-stats.html > > Hope someone knowledgeable on PostgreSQL will have an answer. > > I did find this from 2006. https://www.postgresql.org/message-id/ > eg5op3$ria$1@sea.gmane.org Uh, the only way I know to do that is to query pg_stat_activity like this: SELECT * FROM pg_stat_activity WHERE state != 'idle' AND backend_type = 'client backend'; However, the purpose of why you are using these values probably is not going to translate to Postgres easily. -- Bruce Momjian https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.