Cost of keys-only query compared to get query (google app engine)

风格不统一 提交于 2020-01-15 16:47:08

问题


I've been reading into the cost of datastore calls in the google app engine lately (both in terms of pricing and time). I just have a quick question about a keys-only query vs a get query.

If my only concern was to check if an entity exists, I could go about it in two ways: use get and check for an exception, or use a keys-only query and check for the size of the result. If I am to understand this correctly, keys-only queries are free while a get query will cost. Therefore, it would make more sense in terms of cutting back on the pricing, to use keys-only queries rather than get queries to check if an entity exists. Am I correct?

If so, would the time cost make much of a difference? I know that get queries are faster than normal queries, but I am not sure how the performance compare for keys-only queries. If it is negligible, then I should stick with keys-only queries.

Thank you.


回答1:


A keys-only query means that you'll receive back only the keys, not that you're querying only by the keys.

So yes, that could be OK and free if it fits your purposes.

https://developers.google.com/appengine/docs/python/datastore/queries#Python_Keys_only_queries



来源:https://stackoverflow.com/questions/25015190/cost-of-keys-only-query-compared-to-get-query-google-app-engine

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