I have a composite index with 3 properties: a geohash, an enum ('alive' or
'dead') and a string. I want the index to be sorted firstly by the geohash
(the primary sort), secondly by the string and lastly by the enum. I want
this because it seems likely to give the fastest and densest index scan.
But the geohash is a range (inequality) filter. As per the rules stated in
http://code.google.com/appengine/docs/java/datastore/queries.html#Introduction_to_Indexes(reproduced
below) the geohash sort is last, not first. I found that I
could control the other sorts by ... wait for it ... renaming the
properties. When there are multiple equality filters in a composite index,
appengine chooses sort orders going by property names alphabetically. Well
I never.
So my question is: how does appengine traverse its indexes when performing
a query? Index tables can be big too and even if they are held in main
memory the traversal is still performance-sensitive. I cannot find any
documentation on this whatsoever.
An index table contains columns for every property used in a filter or sort
order. The rows are sorted by the following aspects, in order:
* ancestors
* property values used in equality filters
* property values used in inequality filters
* property values used in sort orders
It has occurred to me that appengine is roughshod about its composite index
sorting because its index traversal is so sophisticated it can deal with
anything. Perhaps that's the answer. But the answer should not be "because
we don't know the shape of your data". Regardless of the shape of my data,
a string field is always more likely to be more selective than a boolean.
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.