For all my data in the GAE Datastore I have a model for keeping track of counters/total number of records (since we can't use traditional SUM queries). I want to know the most efficient way of incrementing these global count values whenever I insert/delete a record. This is what I'm currently doing:
But this seems quite sloppy to me. Any thoughts on a better way to do this?counter = DBCounter.all().fetch(1) dbc = DBCounter(totalTopics=counter[0].totalTopics+1) dbc.put()
Answer:
AppEngineFan's excellent blog also has info on scalable non-sharded counters, see this one which uses task queues and points to the previous article on using cron jobs instead.
0 comments:
Post a Comment