Datastore cannot do this for you in one request. A data warehouse query always returns a sequential block of results from an index, and an index always consists of all objects of a given type, sorted according to any orders. There is no way for a query to skip items only because one field has duplicate values.
One option is to restructure your data. For example, enter a new entity type representing "area". When you add a tutorial, you create the corresponding "area" if it does not already exist, and when you delete Tutoral, delete the corresponding "area" if there are no tutorials with the same "area". If the amount of teaching aids in this area is stored in each area, this may not be too burdensome (although maintaining things compatible with transactions, etc., It would be rather inconvenient). I expect that the entity key can be based on the realm row itself, which means that you can always perform key searches, rather than queries to retrieve region objects.
Another option is to use the job in the queue or the cron job to periodically create a list of all areas, accumulating it for several queries if necessary, and put the results either in the data warehouse or in memcache. Of course, this means that the list of areas may be temporarily out of date (or if there are constant changes, it may never be fully established), which may or may not be acceptable to you.
Finally, if there are very few areas compared to study guides, you can do this on the fly by requesting the first workbook (sorted by region), and then requesting the first tutorial, whose area is larger than the area in the first place, and so Further. But this requires one request per separate area, so it is unlikely to be fast.
Steve jessop
source share