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 1w7lEZ-005fVa-2R for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 02:23:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w7lEY-00EHa4-0O for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Apr 2026 02:23:06 +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 1w7lEX-00EHZp-2h for pgsql-hackers@lists.postgresql.org; Wed, 01 Apr 2026 02:23:06 +0000 Received: from mail-oo1-xc35.google.com ([2607:f8b0:4864:20::c35]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w7lEV-00000002HKW-1kwl for pgsql-hackers@postgresql.org; Wed, 01 Apr 2026 02:23:05 +0000 Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-662efd1bdd4so316583eaf.0 for ; Tue, 31 Mar 2026 19:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775010181; cv=none; d=google.com; s=arc-20240605; b=J6+98rvtGBdRhl+dihUkaeKd2Ivubf6rp9ApAS+VaOKOTQuocFqoAP0RNcKAYhFwfh QpHHf2UH4fpPk3U1BWdsTME+ixBAc4VCcmf+CZWQR8kG60rROmg5gxKFTQKx6Zbd0QuT zey51+LC8bRam4ncdf1s0jQNI3c131l3fvdUttFuBAko66Xa9So56CAUwJUzWfcvV36S /Q863fFPZ7zUwi/WPmxbwLKlk/f9o2HY13sA/tGBryw0CG2n9Q/1Hv0ri9KtIHAgCkL2 i307Nsjqkv/lFrL82R1w7t+KaoFjHIwZquN55kji9hx0sNBpIPurv7l2vjFwDErRzWBS ewGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=IbjDwwgZ+QuwkplE/rfnOzDW3R3VNCqRSoyQ+8KTOdU=; fh=33OU7BWuulPFH378PdKTnpeW+jw3IP20DTmpLDeQ3pE=; b=CpqMZuDAfbF/vjgcevZuzggqtBKimiaoNa7G+fPLUrkPmW4ci3lAnv5obFJII5ld2Z eq/kEk8UNLZ92iUSeokI3p/AOFiq7MD3nyXELieSKVEJhlv/1mtFhGdyd8os4QJyXqMB eiKviQUcs7LMo11T7+XM0bkN7BvF+hujNZUoecDeG1i8UcADxx3ddtd4o5s43AWWeK61 LZx8G8WzofGCvi8B8Yy0Pxv6bnXdmQhRSAGaNr9kVqPxtAjPnWsCNwcetSGZPli0cV6c 4KkqVTJU+me6riycHk7gXXi9hSkZbARRP3o/QiuGcqkn7VmAh8brYp1NxitN/nSBM3lx gahw==; 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=1775010181; x=1775614981; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=IbjDwwgZ+QuwkplE/rfnOzDW3R3VNCqRSoyQ+8KTOdU=; b=TN6GEIm7pVXo2/3xWcc4jDs4/pr+NZ6nMgIqodckqPSmGBIXXTPP1wuZNuWKbnTWGB oNcZ5rxV41y06SuYjDvLtNHm7utSCowJrmKjjHdeFLmcEGPvmv434k4YfAkYaqlbKsGn BMk4HK5bonlpifc/W7AAp4MWuEI87otL+EWTo8yLnSsZJO1g6eINU5neR6xGaNJixNlu aw47lm/lF5oFEe00u2tvtQLPh5aJmvlwQPbOXl72e6SVlGuPsTXT4NzmqZLSCPa92dlb qTNf14OZBlbNiYXy6tKfD02+TeL/9hZoFwHy4CEOYnLZAM57B7V/QaHWub46airwp6Op q4mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775010181; x=1775614981; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IbjDwwgZ+QuwkplE/rfnOzDW3R3VNCqRSoyQ+8KTOdU=; b=FgXCU+/Eg9zJrgN6A7tjCGcNS/v63NE+TyKd+a3HNO7iIJXTG2FA+KUTXvvzRxOu0J JFLz3PDA0vjhM3pivorUFPtTanJjZ5xOC8Y0Bz2fxLLMF/JiRZaFxk1fKTnT4jLiez32 N9/caxzZZIb6nSLp0bRp30Ug0xOlzJNyOAVuyyIoMStuwGPE8aI/cfeZGSqz18YZckos JrCjdjU8MSgw2yVmhLdDnL4TD+7MxL9qa6AlL7TjUizTdAq4rZGCGFkPprF+uk/BrSgW 2dn5Wpj3g5fO9pL/1FN5uZ0j11F4ZcGbxcnHnxO5q3Xz29NTwUxIndarE/gPwB8d6uRS /l3A== X-Gm-Message-State: AOJu0YzpDDhSDCrg0+L6Xswp1qSRoc3BU8COcbY2RHzo6H7yvP+83GNA JJs5Z7Gx6dqK1loSKyjUlq2x9lRbYd3K/o5m84i/9w1wfGFwUH2vMv6+QGR0oBIHbK8U8TJzRJM 6JvvYXjImbg3MuJ9qVR6jsf7/6l17b7iCDtVG9y69nQ== X-Gm-Gg: ATEYQzxiwdIRt8e0L3dTwqmpDL6DFTHcXZZ7npgH8x4lysAGV+xH7jyXr6tgyIiFCAi UHwPDfjtFtovz3htBfA2eEK8PIYgMwsByUqFUeWsZBTvMi8CbEToKX3LywRB9+PrhU2/MJatuY0 a0IHs43rAMEx9s36FklB6eeomnKwfrz7Ke3aBf7woflXnvvD54eq8K8DmppJXdhNhbCpMCuj1cG X2KEBk1Mssn4ohDMCMtVqWGusenj7/kiJIVsiujTwwSCLW/jyRswjBNyJr/WAmmG7cG2pOYWG75 yUVskb3cHD0pJzxJoZvpXv2+iMTML6VYDq0OFHw= X-Received: by 2002:a4a:ee0f:0:b0:67c:28d6:430e with SMTP id 006d021491bc7-67faba3db5bmr827943eaf.28.1775010181464; Tue, 31 Mar 2026 19:23:01 -0700 (PDT) MIME-Version: 1.0 From: Raghav Mittal Date: Wed, 1 Apr 2026 07:52:49 +0530 X-Gm-Features: AQROBzBzL6eJiRKKksfGdNv-TmHPjrTVNASkY6-DXGSwfQ7qXl9SkvfNp__qsCs Message-ID: Subject: Proposal: Track last-used timestamp for index usage To: pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="00000000000056c995064e5cc33b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000056c995064e5cc33b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi all, I=E2=80=99ve been exploring index usage statistics in PostgreSQL and notice= d 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=E2=80=99s interest. Thanks! --00000000000056c995064e5cc33b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi all,

I=E2=80=99ve been exploring index usag= e statistics in PostgreSQL and noticed that
pg_stat_user_indexes only pr= ovides cumulative counters (idx_scan), but not
recency information.
<= br>Problem:
- Counters reset on restart or pg_stat_reset()
- No way t= o determine when an index was last used
- Makes it hard to safely identi= fy unused indexes

Proposal:
Introduce lightweight tracking of las= t-used timestamp for indexes.

Possible approach:
- Mark index usa= ge in executor (cheap signal)
- Background worker periodically updates l= ast_used_at
- Avoids overhead in query execution path

Questions:<= br>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=E2= =80=99s interest.

Thanks!
--00000000000056c995064e5cc33b--