Efficient Query Strategy: keys only query + memcache in appengine?
I currently cache all my entities in my appengine datastore by key in memcache.
Is it more efficient for me to do all my queries as KEY ONLY queries and then getting the actual entities fro开发者_JAVA百科m memcache? Obviously doing a batch get on entities that are missing from cache. In general is that more efficient that doing a simple query from the datastore that returns the entire entity.
Doing this may be marginally cheaper, but since you'll probably have to fetch at least one entity that was missing from memcache, you won't save much time with this approach. A much better solution is to store the result of a query in memcache, so you can fetch the result set with a single memcache get.
Yes. It's faster, and less expensive.
http://code.google.com/appengine/kb/postpreviewpricing.html#operations_charged_for
- Read operations (Query, Entity Fetch) will cost $0.07 per 100k operations.
- Small operations (Key Fetch, Id Allocation) will cost $0.01 per 100k operations.
Yes, key-only queries are cheaper because they only have to read from an index.
If you're storing entities in memcache, be sure to serialize them to protobufs first.
精彩评论