Enhance statistics reset functions to return reset timestamp

From: Shinya Kato <shinya11(dot)kato(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Enhance statistics reset functions to return reset timestamp
Date: 2025-08-08 04:18:39
Message-ID: CAOzEurQbGm6c4GH=pXo2tPz_aL-=bLFfoujij2zFph1LtnhM1A@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi hackers,

I would like to propose a series of patches that enhance the behavior
of various statistics reset functions by making them return the reset
timestamp. This change improves usability and aligns with the behavior
introduced in commit dc9f8a798[1], where pg_stat_statements_reset()
was updated to return the reset time.

The following functions have been modified to return a TIMESTAMP WITH
TIME ZONE value indicating when the statistics were reset:
- pg_stat_reset()
- pg_stat_reset_shared()
- pg_stat_reset_single_table_counters()
- pg_stat_reset_backend_stats()
- pg_stat_reset_single_function_counters()
- pg_stat_reset_slru()
- pg_stat_reset_replication_slot()
- pg_stat_reset_subscription_stats()
- pg_stat_clear_snapshot()

For pg_stat_reset_backend_stats() and
pg_stat_reset_replication_slot(), the functions return the reset
timestamp when a valid input is provided. If an invalid input is given
(e.g., an invalid backend PID or replication slot name), the functions
return NULL.
This allows users to easily determine whether the reset operation was
successful based on the return value.

Thoughts?

[1] https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=dc9f8a798307244d791b71f666f50de319799e7c
--
Best regards,
Shinya Kato
NTT OSS Center

Attachment Content-Type Size
v1-0001-Make-pg_stat_reset-return-the-reset-time.patch application/octet-stream 7.5 KB
v1-0002-Make-pg_stat_reset_shared-return-the-reset-time.patch application/octet-stream 14.5 KB
v1-0003-Make-pg_stat_reset_single_table_counters-return-t.patch application/octet-stream 6.3 KB
v1-0004-Make-pg_stat_reset_backend_stats-return-the-reset.patch application/octet-stream 4.8 KB
v1-0005-Make-pg_stat_reset_single_function_counters-retur.patch application/octet-stream 6.1 KB
v1-0006-Make-pg_stat_reset_slru-return-the-reset-time.patch application/octet-stream 7.3 KB
v1-0007-Make-pg_stat_reset_replication_slot-return-the-re.patch application/octet-stream 8.8 KB
v1-0008-Make-pg_stat_reset_subscription_stats-return-the-.patch application/octet-stream 6.1 KB
v1-0009-Make-pg_stat_clear_snapshot-return-the-reset-time.patch application/octet-stream 8.8 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2025-08-08 04:31:03 Re: Proposal: Conflict log history table for Logical Replication
Previous Message shveta malik 2025-08-08 03:28:21 Re: Proposal: Conflict log history table for Logical Replication