开发者

GAE -- Queries on sharded properties

I understand the theory of sharding values in Google App Engine,as outlined here:

http://code.google.com/appengine/articles/sharding_counters.html

but what happens when I want to run a query on a value that I've sharded? I can't simply query against the value, because it's been split up randomly amongst N different counters. Is the solution just to sum these values back up occasionally to update my main entity? I'm curious to see what solutions others have come up with to this开发者_运维问答 problem.

EDIT: I just discovered the Task Queue API, and it looks like it might be a solution to updating the main value in the background. Anyone tried using this in parallel with sharding?


you're right, you can't use the total sum in another datastore query in a single shot, since it's split between the shards. however, you can run an initial query to gather all of the shards, sum them in memory, and then run your original query using that sum.

beyond that, yes, the task queue is definitely a good approach to doing work like this in the background. take a look at this talk for ideas:

http://www.google.com/events/io/2010/sessions/high-throughput-data-pipelines-appengine.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜