Re[2]: [PATCH] Add last_executed timestamp to pg_stat_statements

From: "Pavlo Golub" <pavlo(dot)golub(at)cybertec(dot)at>
To: "Sami Imseih" <samimseih(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re[2]: [PATCH] Add last_executed timestamp to pg_stat_statements
Date: 2025-12-11 11:31:39
Message-ID: em5be966c3-9086-4f3f-b516-97444b854fdf@10e48d49.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

>Hi,
>
>Thanks for raising this. I did not look at the patch, but I have some high
>level comments.
>
>> I would like to propose adding a last_executed timestamptz column to
>> pg_stat_statements. This column records when each tracked statement
>> was most recently executed.
>
>I do think there is value in adding a last_executed timestamp.

Thanks for your support!

>Can pg_stat_statements.stats_since help here?
>
>for example "where stats_since > last_poll_timestamp" ?

Actually no, monitoring tools fetch snapshots to find the difference
between snapshots.
Data for every statement is changes after each execution.

But stats_since is inserted only once when the new statement execution
appears and is never updated during next executions.

>
>
>The client does have to track the last_poll_timestamp in that
>case.
>
>[0] https://www.postgresql.org/message-id/flat/CAA5RZ0s9SDOu+Z6veoJCHWk+kDeTktAtC-KY9fQ9Z6BJdDUirQ(at)mail(dot)gmail(dot)com
>[1] https://www.postgresql.org/message-id/03f82e6f-66a3-4c4d-935c-ea4d93871dc1%40gmail.com
>
>--
>Sami Imseih
>Amazon Web Services (AWS)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2025-12-11 11:34:19 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Ajit Awekar 2025-12-11 10:52:33 Re: Periodic authorization expiration checks using GoAway message