Re: equivalent of @@TRANCOUNT PostgreSQL

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: dave(at)davebolt(dot)co(dot)uk
Cc: 'Julien Rouhaud' <rjuju123(at)gmail(dot)com>, mustafa(dot)pekgoz(at)forenda(dot)com(dot)tr, 'Pgsql-admin' <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: equivalent of @@TRANCOUNT PostgreSQL
Date: 2021-05-29 15:08:16
Message-ID: 20210529150816.GB23127@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Sat, May 29, 2021 at 03:34:41PM +0100, dave(at)davebolt(dot)co(dot)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(at)sea(dot)gmane(dot)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 <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

If only the physical world exists, free will is an illusion.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Thomas Kellerer 2021-05-29 18:15:44 Re: equivalent of @@TRANCOUNT PostgreSQL
Previous Message Tom Lane 2021-05-29 15:01:10 Re: equivalent of @@TRANCOUNT PostgreSQL