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.
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