Re: Time-based trigger

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Time-based trigger
Date: 2012-09-18 16:11:26
Message-ID: 50589D2E.2050705@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 09/18/2012 10:03 AM, Szymon Guz wrote:
> On 18 September 2012 17:59, Robert Sosinski
> <rsosinski(at)ticketevolution(dot)com <mailto:rsosinski(at)ticketevolution(dot)com>>
> wrote:
>
> We have a table, which has items that can be put on hold of 5
> minutes (this is for an online store) once they are placed into a
> cart. What we need is for this hold to automatically expire after 5
> minutes. Right now, we put a time stamp into the row (called
> hold_until) at 5 minutes into the future, and select items where
> hold_until is less then now().
>
> Would it be possible to change this to using a boolean that is set
> to true when item is put on hold, and have something like a
> time-based trigger automatically update the held boolean to false
> after 5 minutes pass.
>
> Thanks,
>
> --
> Robert Sosinski
>
>
> It is not possible right now, however I'd rather create some cron job
> which updates the boolean value if needed and runs each minute.
>
> - Szymon
Yeah, seems like a boolean would give no indication of when it was set.
I would rather have value "held_at" as a timestamp and the cron job
would null those "held_at" more than 5 minutes ago. Not sure if an
index on "held_at" would help in "select where held_at is not null".

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2012-09-18 17:19:27 Re: Index creation takes more time?
Previous Message Yvon Thoraval 2012-09-18 16:08:25 Re: On Ubuntu 12.04 i do have two psql one of those isn't working