Re: Proposal: Track last-used timestamp for index usage

From: SATYANARAYANA NARLAPURAM <satyanarlapuram(at)gmail(dot)com>
To: Raghav Mittal <mittalr086(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Proposal: Track last-used timestamp for index usage
Date: 2026-04-01 02:50:26
Message-ID: CAHg+QDdoo0u+WWuHYOnKn+ygYrg87yufiPUS_X+=0BrUEM3JYw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Raghav,

On Tue, Mar 31, 2026 at 7:23 PM Raghav Mittal <mittalr086(at)gmail(dot)com> wrote:

> Hi all,
>
> I’ve been exploring index usage statistics in PostgreSQL and noticed that
> pg_stat_user_indexes only provides cumulative counters (idx_scan), but not
> recency information.
>
> Problem:
> - Counters reset on restart or pg_stat_reset()
> - No way to determine when an index was last used
> - Makes it hard to safely identify unused indexes
>
> Proposal:
> Introduce lightweight tracking of last-used timestamp for indexes.
>

Could you elaborate the problem trying to solve here? As you mentioned
idx_scan already tracks the usage. Periodic snapshots should provide the
usage over a period of time. What is the purpose of exact timestamp?

Thanks,
Satya

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2026-04-01 02:53:48 Re: Refactor query normalization into core query jumbling
Previous Message Sami Imseih 2026-04-01 02:46:16 Re: Add pg_stat_autovacuum_priority