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 1vVn61-007wRo-2M for pgsql-general@arkaria.postgresql.org; Wed, 17 Dec 2025 08:41:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVn60-00BMlk-2I for pgsql-general@arkaria.postgresql.org; Wed, 17 Dec 2025 08:41:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVn60-00BMlc-1G for pgsql-general@lists.postgresql.org; Wed, 17 Dec 2025 08:41:21 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vVn5z-0017HH-37 for pgsql-general@lists.postgresql.org; Wed, 17 Dec 2025 08:41:20 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-b79f8f7ea43so57250466b.2 for ; Wed, 17 Dec 2025 00:41:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1765960878; x=1766565678; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=LNQ7qJ6OgisXFdzJJiBmam595ojfGGPXgLzARQlNmoA=; b=RMWucjHHIqInckKmW5QR0JdW2RTkfirXgPnKAL/LiFqEwN4WieFnRC4RQZn1F5eRhs XqebwocwJ/arsNoPZmFXJMF923Oid1V6bzbsBCxDEHK/f4B+ZgzbxQCI6VvMb7lX5oeN uallfF5SznHgPB9oiLzMZjvmfohi78sQ3FdLw0zDxXYLS78QxyUdG52+LYzPqG17jl6g ELxez5282h1822oAveJ9MgTNm2qbZt9FP8Xgzr60Zvv6PKTZJi4fZpaQ+mBFxvLl8tog XEJGaw7jtLR7JRtONpCw974IOxyK8ZFhAoy2V2yhO1DCjvMq/D7dSsZfzwzYaKzj5ukg MxjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765960878; x=1766565678; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LNQ7qJ6OgisXFdzJJiBmam595ojfGGPXgLzARQlNmoA=; b=s9cVeoEJnYCNDPoWg3/OUQMjS33FB1WS2yydrw+PpoYXbp+3WdMdZNG3n0Yo3CQZz7 +Ws/cfU3BEyFprD5W7GnzcmwmGlNCNzvRHiADTprZntng6hV+h3HLJrkY0pxEXla5d8z a33lsSHbK1VgnRmk9nHrQUpdPht7UjdjAz9UFl11ma+PRH+zgZmSuRmalZ3zmUT6FdcG 3hMHuaV0E+gCZ2jywYviAVfufm5VKDCC5hMUalvlePFHvBbhJzPL/B6vs+tIKTVEpYZe 13VXrHdH2HP4kHv7Gua6zvanoHRmI+RYqG9TiRocur8MtX/ftwINdwCGw//6xQAK6ZTb 77jQ== X-Forwarded-Encrypted: i=1; AJvYcCUzMMbkug9pe89zKLtLI//g+YSh9uHUEaLjt70kLYPA9dg4oamGTBgmhUcXmKRfmO8j2Vit7CRyoMYNaqkv@lists.postgresql.org X-Gm-Message-State: AOJu0YwB4FwZuInSs3KVqygFXcbdm7KZ8SOgw3BVIeYTJn9xEEqb2Xno Ye5vSFYaTCTzbmVXYtlgITw83aSlcxok1TuYkB6XsShD+WTFxuUW3QJnStPU2IEaFto= X-Gm-Gg: AY/fxX5KjmKNJhmvqsCkbRlj/6FpJsRgSQVUOtC4HkyQqJhKQEkx0W6utBzXsy9gxm8 NmL/W1QlJbf8L0G19Oa65MR+S277IYQIrn6tmAWJFhjhIx3WHzRBNhNFxQkYhhP5TsgKLroIy9F N7HnM3Czgy1Nmvxr9uKi9Uw810GRY/vfJWEYZtJReu42QMui792TdqvnJx6YsTHhoKG3c2BxO7u Mq84Ukp1KmPhejcvVlbltFBgV96HpYZBQqxDLK1ZtSdbl2U8J97n8l9L9QQi5bxAbcbLcv2RVwh DDWC2uUipSjRZXPy0Y7eLfzFy6uX0xqtccitmhuUD3Y4NJq5O/T2PyrfNp2SUb9TkfhMZ8ldu+I UfQGzVxfKzSOPmEkBSs1lACCLg/4QFXkaOS7DjWICJ8D4FLwnMO+jXq72yxVT9CPljQ6VtgN11k XtFpYi40Kai20NbqEsKhQ4Xkb6sfBRmF184Ck7nV9I X-Google-Smtp-Source: AGHT+IHxG+NEmdCYKyjY5iBmH+SVzspCwwDe6SBBeN9Hq+E9MzG23560vOHbEy7QaPa/djwqONmoag== X-Received: by 2002:a17:907:6eac:b0:b73:9792:918b with SMTP id a640c23a62f3a-b7d236b50bamr1908579266b.27.1765960878038; Wed, 17 Dec 2025 00:41:18 -0800 (PST) Received: from laurenz.albe-K4N0CV00F97414D ([88.116.133.170]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b7ff7e5e79esm385726266b.46.2025.12.17.00.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 00:41:17 -0800 (PST) Message-ID: Subject: Re: Record last SELECT on a row? From: Laurenz Albe To: Matthias Leisi , "pgsql-generallists.postgresql.org" Date: Wed, 17 Dec 2025 09:41:17 +0100 In-Reply-To: <287E4DF6-35A2-4062-AEBA-32DB1DE35C5D@leisi.net> References: <287E4DF6-35A2-4062-AEBA-32DB1DE35C5D@leisi.net> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2025-12-17 at 08:40 +0100, 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: appea= red in a > SELECT result). The ultimate goal would be that we can =E2=80=9Eage out= =E2=80=9C rows which have not > been accessed in a certain period of time. >=20 > 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 column. But sinc= e we don=E2=80=99t control the > application, that=E2=80=99s not an option. On the other hand, we have ful= l control over the > database, so we could put some other =E2=80=9Eobject=E2=80=9C in lieu of = the direct table. >=20 > 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