Re: Record last SELECT on a row?

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Matthias Leisi <matthias(at)leisi(dot)net>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Record last SELECT on a row?
Date: 2025-12-17 08:41:17
Message-ID: a5858d490737bac1696b24abbada58210e2c68eb.camel@cybertec.at
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 2025-12-17 at 08:40 +0100, Matthias Leisi wrote:
> An application (which we can’t 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 we can „age out“ rows which have not
> been accessed in a certain period of time.
>
> If we had full control over the application, we could eg use a function to select the
> records and then update some „last read“ column. But since we don’t control the
> application, that’s not an option. On the other hand, we have full control over the
> database, so we could put some other „object“ in lieu of the direct table.
>
> Any other ways this could be achieved?

I don't think that is possible. You could log all statements, but that won't show
which rows are accessed.

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2025-12-17 12:42:41 Re: Record last SELECT on a row?
Previous Message Laurenz Albe 2025-12-17 08:38:43 Re: [GENERAL] Retrieving query results