Re: How to implement expiration in PostgreSQL? - Mailing list pgsql-general

From David G. Johnston
Subject Re: How to implement expiration in PostgreSQL?
Date
Msg-id CAKFQuwYOy+WgpX_tWc+oN74MBYwFCox_3=RUzKuTdp6C5CgjtA@mail.gmail.com
Whole thread Raw
In response to Re: How to implement expiration in PostgreSQL?  (Glen Huang <heyhgl@gmail.com>)
List pgsql-general
On Thu, Apr 1, 2021 at 7:23 AM Glen Huang <heyhgl@gmail.com> wrote:
> I'd say that was onerous and you could get the same effect with a
well-crafted query that targetted only those that might possibly expire.

I wish one cron job could rule them all, but since a person can decide to join at any time, her expiration (e.g., after 1 hour) can also happen at any time. So one cron job won’t cut it if a member’s expiration has to bee accurate.

There are indeed a number of moving parts here but I would suggest that setting up a more static data model would be a well advised starting position.  Write queries that take the expiration timestamp into account, noting whether the time it represents is in the past or future.  The reduced update burden will be a boon for both complexity of the updates themselves as well as for your I/O subsystem that has to handle vacuuming all of those dead tuples.

David J.

pgsql-general by date:

Previous
From: Brian Dunavant
Date:
Subject: Re: Is replacing transactions with CTE a good idea?
Next
From: "Theodore M Rolle, Jr."
Date:
Subject: Slick way to update multiple tables.