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 1vVtOT-009U8Q-1V for pgsql-general@arkaria.postgresql.org; Wed, 17 Dec 2025 15:24:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVtOR-00Dhip-3B for pgsql-general@arkaria.postgresql.org; Wed, 17 Dec 2025 15:24:48 +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 1vVtOR-00Dhih-25 for pgsql-general@lists.postgresql.org; Wed, 17 Dec 2025 15:24:48 +0000 Received: from mail-oi1-x22a.google.com ([2607:f8b0:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vVtOP-001FXa-34 for pgsql-general@postgresql.org; Wed, 17 Dec 2025 15:24:48 +0000 Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-44fe903c1d6so1345848b6e.0 for ; Wed, 17 Dec 2025 07:24:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765985084; x=1766589884; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=2xA8iRevO9xUGtPhruiP2o9WqY51qjxXxu+Aes0an/k=; b=FFiyk8bkdOJVuA9L/SmlbMtLgo7vnaN6UussqeI2ycAi/H0UJ0r+YCIf8FNY1sRip4 JG3E0LTxnolqeEBYb6mVaOfCkpG21cWQAVb18DrA9HTd5XLmLr4NOe//ITku+ju9E4U2 GkK9LY/ffq6saFTf8XDSBzweVxaTzeR2dDK3WDTZQmRvXy30zGLAy9ISFnREc7A7q/19 VzcinXeVMz93l7ij/C7O/dnlRQMKalI7fU8F8+GSfx+rkhWFAsdFbuF7xjrGbZVL9rRw nroQSYIPcpOlE5vLSM8Ss+lE46Wkny31wEcA8saT+ySffWiVVcESIGUR1lNA6mRm0K5M G15g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765985084; x=1766589884; h=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=2xA8iRevO9xUGtPhruiP2o9WqY51qjxXxu+Aes0an/k=; b=WgqxB9rNgmdWzpfNkcALcCBjiZyzBbDCajcgBg2UrNGVx1HIoIJgDceAaLUz/RwRCR klMPk8h+YQCJ3boJ/5WUWDEesaMZiVXPRta6bPmntqtkKZwuo0aEq87XGGAzjnY0j4Ov Fcepy1itAjqf4noE/eMJ9OUUZslHfp/l9JgJTcKpWci14I4LsVyfEroj3z5uecNBKQkL 8Nqb6QkrwIt/dcjIhFzBAIygnnN9MT6YgnNT5WeTVbvjoLjq+M4ihT0a0slNYtc1meeH EMTfuTguVNztls5ucQ1mfMiXUMjyh8C0jM3CTKffl8GXuEfCuxK8i2bkL1Y9ykjFYoeq 4YOw== X-Gm-Message-State: AOJu0Yz4x4NE66WPbxOPz3+Znml8zMSSdUR/9/pIwjH32lVBfYfLRQri Bsx+pl1H3aICFFKNZ3xV0/STmAXU+nw3OJdDgebul83HC9PPsqo+3+kR87axTM520lJQprjXV0a 05zkziDfnYnTtrCvya4wImax8Vn1IU3VZow== X-Gm-Gg: AY/fxX6kY1x8W0Gx4IhgiTUnyzV+xUm9TrbDPoEXeWdqDNcBMmhFeddRC37wM3v/JGB Ra8YpPf3VjXbAwIx7vMpj2v1S/W09qKNNSVme8yGMAOVx4OlNtIf37Srtn3eEhOCjbnRK6sKb0Z xf1GUP2ik3PTyyf1c0/3OI6mA7Oa4blu9WA5/vK19BlsKawc4LtskEijyK/cB3xxZSA+MPxHl6+ UOUzGOcroRuvLGWO+sOgYAltG4bpyMehQQPJfN/DNyg++XnTBzGBpCVvDLXS4t58H8Nk3rAcn4t dQ84paY= X-Google-Smtp-Source: AGHT+IETY5eam78jR26U+loNx3bv8rUooWN8RD+05SXj+JCh2qSQEJxbBrcS5wzqL5QnmdbCp9vxVuqI8/uauJXW6CY= X-Received: by 2002:a05:6808:4fec:b0:450:4367:111 with SMTP id 5614622812f47-455ac9d8391mr8810760b6e.66.1765985083829; Wed, 17 Dec 2025 07:24:43 -0800 (PST) MIME-Version: 1.0 References: <287E4DF6-35A2-4062-AEBA-32DB1DE35C5D@leisi.net> In-Reply-To: <287E4DF6-35A2-4062-AEBA-32DB1DE35C5D@leisi.net> From: Ron Johnson Date: Wed, 17 Dec 2025 10:24:32 -0500 X-Gm-Features: AQt7F2oVYODhiHIy9sTSVezTraHkUwD-3Mr8hENAJM8YEsRM6u4oiH28thnTaGY Message-ID: Subject: Re: Record last SELECT on a row? To: pgsql-general Content-Type: multipart/alternative; boundary="00000000000099b05d064627711e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000099b05d064627711e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 17, 2025 at 2:41=E2=80=AFAM Matthias Leisi = wrote: > An application (which we can=E2=80=99t change) is accessing some Postgres= table, > and we would like to record when the rows in that table were last read > (meaning: appeared in a SELECT result). The ultimate goal would be that w= e > can =E2=80=9Eage out=E2=80=9C rows which have not been accessed in a cert= ain period of time. > > The table contains some ten thousand rows, five columns, and we already > record created / last updated using triggers. Almost all accesses will > result in zero, one or very few records returned. Given the modest size o= f > the table, performance considerations are not top priority. > > If we had full control over the application, we could eg use a function t= o > select the records and then update some =E2=80=9Elast read=E2=80=9C colum= n. But since we > don=E2=80=99t control the application, that=E2=80=99s not an option. On t= he other hand, we > have full control over the database, so we could put some other =E2=80=9E= object=E2=80=9C in > lieu of the direct table. > > Any other ways this could be achieved? > pgaudit might satisfy your needs, since it would only log SELECT statements on that one table. You'd still have to grep the log file, so the information wouldn't be real-time, but that's *probably* not important. --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --00000000000099b05d064627711e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Dec 17, 2025 at 2:41=E2=80=AFAM M= atthias Leisi <matthias@leisi.net<= /a>> wrote:
--
Death to <Redacted>, and butter sauce.
Don't boil me= , I'm still alive.
<Redacted> lobster!
--00000000000099b05d064627711e--