开发者

Google App Engine large IN clause query

I have an Account entity that has a facebook id.

Sometimes, the client might send all facebook ids (the clients facebook friends) to the server.

We want to select all Accounts IN the facebook ids the client provided.

Looping and calling get on each facebook id seems rather slow, consider开发者_JS百科ing people might have 1000+ friends. Further more, GAE is limited to 30 queries with IN clause.

Has anyone had a similar situation? How did you handle it?

Thanks!


You can set up a model that uses the facebook ID as a key which allows you to use Model. get_by_key_name(key_names=fb_ids) to fetch all the models with keys in fb_ids at once.

e.g.

class FBModel(db.Model):
   account = db.ReferenceProperty(reference_class=Account)

When creating the model:

model = FBModel(key_name=fb_id)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜