We are trying to query App Engine datastore for some general stats using NDB. They don't need to be 100% accurate (i.e., I'm not concerned about eventual consistency); they just need to reflect generally the count of entities.
With NDB, we are issuing simply something like:
query = MyModel.query(MyModel.source==source, MyModel.created<=some_time).order(-MyModel.created)
count = query.count(keys_only=True)
This is timing out after around 60s. We use entity groups and transactions fairly regularly, but I'm hoping that those would not impact these count queries. We currently have around 4.2M entities of MyModel, though the source filter would be limiting this down to perhaps 210,000.
Is there an alternate way to count numbers of this magnitude, without a bunch of custom memcache-y logic? Remember, the numbers don't need to be exact, just "generally correct".
MyModel.query().filter()...in there... - Jason A. Collinsqueryto achieve the same effect. Why do you needorderif you are just counting? - bossylobstercountquery though. It'd be nice to find out; I'll see what I can do. - bossylobster