Re: How to implement expiration in PostgreSQL?

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Glen Huang <heyhgl(at)gmail(dot)com>
Cc: Tim Clarke <tim(dot)clarke(at)minerva(dot)info>, "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: How to implement expiration in PostgreSQL?
Date: 2021-04-01 15:56:31
Message-ID: CAKFQuwYOy+WgpX_tWc+oN74MBYwFCox_3=RUzKuTdp6C5CgjtA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Apr 1, 2021 at 7:23 AM Glen Huang <heyhgl(at)gmail(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Theodore M Rolle, Jr. 2021-04-01 16:16:54 Slick way to update multiple tables.
Previous Message Brian Dunavant 2021-04-01 15:49:40 Re: Is replacing transactions with CTE a good idea?