Re: help modeling a schedule system

From: Scott Ribe <scott_ribe(at)killerbytes(dot)com>
To: chris h <chris404(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: help modeling a schedule system
Date: 2010-10-06 00:48:18
Message-ID: 363AF467-AD9B-4D2D-89C9-5594A0A1DBEA@killerbytes.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Well, when I did something similar a very long time ago, I put a "next time to fire" column in the table. Each time an event is fired, the application updates that column.

Was a lot simpler than baroque searches for events that would need firing between the last check and now. Was a lot cleaner than creating tons of instances out through the future.

You could create a stored procedure, if you want, to calculate the next time based on all the possible criteria.

You could, have a "last time fired" column that keeps track of when the event was most recently fired, for logging/debugging/info. You could have a trigger that updates that "next time to fire" column each time the "last time fired" column is updated.

--
Scott Ribe
scott_ribe(at)elevated-dev(dot)com
http://www.elevated-dev.com/
(303) 722-0567 voice

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Josh Kupershmidt 2010-10-06 00:56:10 Re: Postgres, DB2 and Materialized Query Tables (MQTs - DB2s Materialized Views)
Previous Message Selena Deckelmann 2010-10-06 00:38:42 Submissions for a PostgreSQL track at MySQL Conf 2011: Due October 25