Is it best to query by keys_only=True then get_multi or just full query?

五迷三道 提交于 2019-12-22 04:04:08

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/11596869/is-it-best-to-query-by-keys-only-true-then-get-multi-or-just-full-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!