My app-engine data model is defined as:
class Event(db.Model):
title = db.LinkProperty();
refresh_interval = db.IntegerProperty();
class EventSchedule(db.Model):
event = db.ReferenceProperty(Event) # referencing the event
refresh_date = db.DateTimeProperty(); # date & time of last successful refresh
I’d like to fetch all EventSchedule items based on the criteria of:
event_schedule.refresh_date + event.refresh_interval >= now
In SQL-land, it would look something like:
DATE_ADD(event_schedule.refresh_date, event.refreshInterval) >= now()
Is this kind of join operation feasible with the data store?
This join operation is not possible with the GAE data store, and is highly inefficient on normal SQL databases as well (since it requires a scan of the entire event_schedule table).
You should instead store a
next_refreshDateTimePropertyin yourEventScheduleentities, initialized to berefresh_date + refresh_intervalwhen the entity is created, and simply test fornext_refresh >= now.