From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Dominique Devienne <ddevienne(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: is pg_stat_activity "transactional"? How fast does it update? |
Date: | 2025-06-10 16:03:48 |
Message-ID: | 16ff305a-9abe-4cb4-98f2-7276d0bf1910@aklaver.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 6/10/25 08:46, Dominique Devienne wrote:
> On Tue, Jun 10, 2025 at 4:27 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> Dominique Devienne <ddevienne(at)gmail(dot)com> 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
>
For more detail see:
https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-STATS-VIEWS
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Jim Cunning | 2025-06-10 20:01:17 | pg_upgradecluster version 10 to 16 question |
Previous Message | Dominique Devienne | 2025-06-10 15:46:50 | Re: is pg_stat_activity "transactional"? How fast does it update? |