public inbox for [email protected]
help / color / mirror / Atom feedFrom: Dominique Devienne <[email protected]>
To: Tom Lane <[email protected]>
Cc: [email protected]
Subject: Re: is pg_stat_activity "transactional"? How fast does it update?
Date: Tue, 10 Jun 2025 17:46:50 +0200
Message-ID: <CAFCRh--LyhHAOYKWE+NDCN8cB4pGiO82p1Ye9pT9T7fv7i2BfA@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <CAFCRh-8WDkn2N+s43fofR4eKHcJC8fiotqWqSGkDQ4Sh4ZYwDg@mail.gmail.com>
<[email protected]>
On Tue, Jun 10, 2025 at 4:27 PM Tom Lane <[email protected]> wrote:
> Dominique Devienne <[email protected]> writes:
> > So when and how fast does pg_stat_activity update, in the face of a
> > PQfinish?
>
> The shared state underlying pg_stat_activity is updated
> immediately when something changes. However ...
>
> PQfinish is asynchronous: it sends a "goodbye" message and then
> closes the connection without waiting for a response. So
> depending on system load, the associated backend could still be
> alive for some milliseconds. There might be other client
> libraries that do that differently.
>
> Another thing that might be biting you is that a backend inspecting
> pg_stat_activity() takes a snapshot of the view's contents and then
> holds onto that snapshot until end of transaction. You can get
> around that with pg_stat_clear_snapshot().
Many thanks Tom. Didn't know either of those facts. --DD
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: is pg_stat_activity "transactional"? How fast does it update?
In-Reply-To: <CAFCRh--LyhHAOYKWE+NDCN8cB4pGiO82p1Ye9pT9T7fv7i2BfA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox