是否最好通过keys_only = True查询,然后get_multi或只是完整的查询? [英] Is it best to query by keys_only=True then get_multi or just full query?

查看:161
本文介绍了是否最好通过keys_only = True查询,然后get_multi或只是完整的查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



据我所知,查询具有NDB的实体不使用本地缓存或memcache,而是直接转到数据存储不像获取关键名称。 (如果这个前提不正确,问题的其余部分可能是多余的。)

因此,一个好的范例是只用keys_only = True进行查询,然后执行get_multi获得完整的实体?



好处是,keys_only = True查询比keys_only = False快得多,get_multi可能会碰到memcache&通过调用get_multi,您的实体现在保存在memcache中,以防您需要再次执行查询。



缺点是您现在有一个RPC查询调用+ get_multi调用,我认为您可以在一个get_multi中调用的实体有多少限制,因此您的有效查询大小可能有限。我们是否应该只使用keys_only = True进行查询,然后执行get_multi?是否存在特定的最小和最大查询大小限制,使得这种技术不如仅执行返回完整实体的查询那么有效? 解决方案

这已经被广泛研究。请参阅 http://code.google.com/p/appengine-ndb-experiment / issues / detail?id = 118


I am using NDB with python 2.7 with threadsafe mode turned on.

I understand that querying for entities with NDB does not use local cache or memcache but goes straight to the datastore unlike getting by key name. (The rest of the question might be redundant if this premise is not correct.)

Therefore would a good paradigm be to only query with keys_only=True and then do a get_multi to obtain the full entities?

The benefits would be that keys_only=True queries are much faster than keys_only=False, get_multi could potentially just hit memcache & by calling get_multi your entities are now saved in memcache in case you need to do the query again.

The drawbacks are that you now have an RPC query call + get_multi call and I think there is a limit to how may entities you can call in one get_multi therefore your effective query size might be limited.

What do you think? Should we only ever query using keys_only=True then perform get_multi? Are there certain minimum and maximum query size limits that make this technique not as effective as just doing a query that returns the full entities?

解决方案

This has been extensively researched. See http://code.google.com/p/appengine-ndb-experiment/issues/detail?id=118

这篇关于是否最好通过keys_only = True查询,然后get_multi或只是完整的查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆