Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w7lfG-005ftD-21 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 02:50:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7lfF-00ENio-0R for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 02:50:41 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w7lfE-00ENig-2m for pgsql-hackers@lists.postgresql.org; Wed, 01 Apr 2026 02:50:41 +0000 Received: from mail-vs1-xe33.google.com ([2607:f8b0:4864:20::e33]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7lfC-00000002HWO-3REW for pgsql-hackers@postgresql.org; Wed, 01 Apr 2026 02:50:41 +0000 Received: by mail-vs1-xe33.google.com with SMTP id ada2fe7eead31-60508c1df45so3110751137.0 for ; Tue, 31 Mar 2026 19:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775011837; cv=none; d=google.com; s=arc-20240605; b=lIGEcxcRrVGwQupcH7w5WQax/z1fLFDNSTkGsrmEnCFt+tDj/hNQAVXemB3mPwLOhC pPexVRcoz27v47aFsBFpdDnu4BroOXsCelmBD1/HgUxsswg0s7b9rpft55tIhU04SBaR nn8CXb2/r0Co/ThTNhXpKsdu1J8Jj1q+WSatAZKDoUfxBk1z0X8J1RueOCQzsH3jGMIK 9M9Nhw44xehSR6D93h2v5aSNKL2g+hhBPdYp18bVyUBsUEbHjtQ455gPRHZ26qtdEf5q NmaASuT/sCGAjlSbZ52lfUpu8GfzUWhLnQCZOTi8pTwzA5CsNixOWb5Dtfy8HsSZGoDU 62YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=dcctbtDfbpNr9JRMfDiWs56mZBzQ2GbosGNfqeReGyU=; fh=ScvsIRBmUuNca92/w3NqXWBHFHm0MrOi2rMD/ubbXV8=; b=kTOnfpImu276sLr7oSZ5xMY2tm0SBOyNWB4LJYMAECVnWpuh5IW44B2PJdx25eJQR9 vTSoxYO9hZTrjVLFeaDBSVEuMvvdSl+bW3o1i+to83UjnWVKFF+CiVq7Wwjh/Dfyv2FO r2FjjltfXkyDhJjQGniuGnxIU2lLrSr7sspvPqRUdr4ipVc8jSpWVVU5dNhSnz1BVxYA EFRA7HzQtBwT3M2hptCd7VuRCNDW+gLoJZHcu7JB2P66YKrSipUFyRpYWCU4rA79tyit g+POTYgjuEX0t+jrVMUrI2DwCVztPFgOTWg+xW3WZTbkoN9sFu0fJOTJIyVUC1pG02VX f49A==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775011837; x=1775616637; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=dcctbtDfbpNr9JRMfDiWs56mZBzQ2GbosGNfqeReGyU=; b=h0UeLqPy1gC3uZ6jTXsMg+huPfO/1SVkIyOhsgvlPik1qT0KhHGm6goBkKOkrhHXQc zB4625BxE6Ae1iZ6jw0ifmy7f3Fy1wK8BMl+Y7Gn8oamfD0wHziUPlctFb3XXyiC7dle mvS2lZ5M2whfwfI2oXM6YwqLxmSnqXKad6YbdfRCp7aLL+3Kw6yh9rQmmIt20CIfPoW1 lzVARGwz3NHr18kaHUw3arqRjERGb2CEB14bDWVzkymdWsSf4SgcjhVbDodx7F+Yrq28 fcqdqRL6WG5OBEdU5Q7NzFSKY98RHc8A1Qop3ZkSNVl+J7/MdF3wvCbCbNKP8aOY6CEP YKmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775011837; x=1775616637; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dcctbtDfbpNr9JRMfDiWs56mZBzQ2GbosGNfqeReGyU=; b=odNd75GxlxJ80TnjYPhOfkXmAIEjUBuO9S/mZWJNW9ZarwOBooPay3Cwvz3d/d6K+6 HFFZVF03OriEVFDYrqjttvdijTmMtFlJGpaTW2p6mhdvzbsgBFkdar9Pm4VkS4B8q7mM lw+c2LtGYT3RPhA0dgTQJl1CxeoN9d/8N9cvevd2gZ2vznwYo3AU0CMAXZqCaYFNWbIb rwGQb0AP18v/MmKDvezc095yKzXteHZ1LjEngLFvPGj6gHMtRduS/ug8RLQq3lEs0zu1 dvajKrjVudnns6zwtNksSY2sylnhwe8/7ZhR1nlt9KoDkmcG6kJVBLq6EdKqX0uaYl/G nA5Q== X-Gm-Message-State: AOJu0YztHsNbCencuiShwekKVm2vZj/kTTBokbAn7uVg9Xr5LCfAC9Dp t2BulmbmXqqO1RZOR+BU/iMrg634x+g+7Ts+5/R6vSi0/3PHaZutUJWRAsO9s7nnfycVUi6b4HP ZvTr6unAgoKNOSu89JPh48VTRgzlPFQw= X-Gm-Gg: ATEYQzy40uOcOIaMOtA1opP/KK5wG5hMjQLZ4BZdv5NUJyvHsIjlbdZFzhso9uZF7BC FUNaxCMS8wtdKqtFYQ0TaUsIGqSDucBnFkElpQ4dfqqd364NwFDqtpo//xFwKwDgk8Mlv7xuYet /Ik3EbrrWSOlfJE1b/x8OTwVoHD/fkSj+Qzl9dJjKdxp5bIc/6xpbvEWk89DHgMp0ScEhHN+wFF b8oTGSCin5H1nTTV5mIMJFCA4KiR/VVIwr9cYeL6oReezZrIjjHOoJ6Fb19VtnARiNA8WTE6Hih u3V56S8= X-Received: by 2002:a05:6102:40c8:10b0:605:2a07:65e5 with SMTP id ada2fe7eead31-60568119f12mr560007137.18.1775011836980; Tue, 31 Mar 2026 19:50:36 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: SATYANARAYANA NARLAPURAM Date: Tue, 31 Mar 2026 19:50:26 -0700 X-Gm-Features: AQROBzD4LjigssKAqISzcr1cqbXaWkRRqyjI4S0OwzcXDqjT9OMJidRas-Sg1SA Message-ID: Subject: Re: Proposal: Track last-used timestamp for index usage To: Raghav Mittal Cc: pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="00000000000003f316064e5d267e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000003f316064e5d267e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Raghav, On Tue, Mar 31, 2026 at 7:23=E2=80=AFPM Raghav Mittal wrote: > Hi all, > > I=E2=80=99ve been exploring index usage statistics in PostgreSQL and noti= ced that > pg_stat_user_indexes only provides cumulative counters (idx_scan), but no= t > 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 --00000000000003f316064e5d267e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Raghav,

On Tue, Mar 31, 2026= at 7:23=E2=80=AFPM Raghav Mittal <mittalr086@gmail.com> wrote:
Hi all,

I=E2=80=99ve been exploring index usage statis= tics in PostgreSQL and noticed that
pg_stat_user_indexes only provides c= umulative counters (idx_scan), but not
recency information.

Probl= em:
- Counters reset on restart or pg_stat_reset()
- No way to determ= ine when an index was last used
- Makes it hard to safely identify unuse= d indexes

Proposal:
Introduce lightweight tracking of last-used t= imestamp for indexes.

<= div dir=3D"auto">Could you elaborate=C2=A0the problem trying to solve here?= As you mentioned idx_scan already tracks the usage. Periodic snapshots sho= uld provide the usage over a period of time. What is the purpose of exact t= imestamp?

Thanks,
<= div dir=3D"auto">Satya

--00000000000003f316064e5d267e--