Hi Phillip,
  There is also a bit of information in some of the datastore
articles, particularly the 'How Entities and Indexes are Stored'
article.
     
http://code.google.com/appengine/articles/storage_breakdown.html#anc-indextables

  What is boils down to is that your indexes are going to be sotred
something like this:
     your_app_id|namespace|the_kind|prop1:True|prop2:the
value|prop3:more values   =  some_entity_key

  When you query, matching rows are fetched (think of a lookup in a
hash-table), then the entities corresponding to the keys are fetched.
So whatever you're doing the range-scan / order on must go last.
Remember, in app engine you can only do an inequality filter on a
single property, there is no fancy index magic going on.



Robert




On Fri, Feb 25, 2011 at 19:48, philip <[email protected]> wrote:
> 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.
>

-- 
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.

Reply via email to