Let’s say I have 1000 entities. I’d like users to find entities through a faceted search in this way:
- user selects filter
- an ajax request is sent to GAE
- server returns the count of matching entities
- repeat until there are only a few entities
In other words every applied filter (just a checkbox) may cause up to 1000 reads (subsequent filters would cost less because fewer entities are returned).
This means that about 10 “searches” (= applying multiple filters) a day may eat up all my 50k free reads quota.
Memcaching results isn’t really an option: if I have 30 filters which one could apply, to store all combinations there would be 2^30=”over a billion” memcache entries (which would all have to be updated when an entity changes by making first a billion datastore reads).
evidently I didn’t get something. How would I efficiently cache or calculate results?
If you only have a 1000 or so entities, your best bet, given the situation you have described, is to keep all 1000 entities in memcache and run your queries in memory instead of the datastore. In-memory query of a 1000 entities should be very fast.
You can convert your entities to protobufs before storing in memcache. See this link.