public inbox for [email protected]  
help / color / mirror / Atom feed
From: Raghav Mittal <[email protected]>
To: [email protected]
Subject: Proposal: Track last-used timestamp for index usage
Date: Wed, 1 Apr 2026 07:52:49 +0530
Message-ID: <CA+dbf3gvWCeF8j_DBjtaPcNmm=E9d_Z7sPdaJRuanGfAw2Rvow@mail.gmail.com> (raw)

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.

Possible approach:
- Mark index usage in executor (cheap signal)
- Background worker periodically updates last_used_at
- Avoids overhead in query execution path

Questions:
1. Has this problem been explored before?
2. Are there known concerns with adding timestamp tracking to stats?
3. Would this be acceptable as an extension vs core feature?

Happy to prototype this if there’s interest.

Thanks!


view thread (3+ 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]
  Subject: Re: Proposal: Track last-used timestamp for index usage
  In-Reply-To: <CA+dbf3gvWCeF8j_DBjtaPcNmm=E9d_Z7sPdaJRuanGfAw2Rvow@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