Ancestor queries don't add significant overhead, so I'm not going to
consider that factor.

As far as other queries go, in general fewer indexed mean better performance
if you are doing zigzag join. However - if an index contains a small number
of results, obviously the query will return faster because there are simply
less results. Otherwise, you end up zig zagging across more indexes, which
probably will result in slower queries. It really depends on the shape of
your data. What have your obvservations been?

Ikai Lan
Developer Programs Engineer, Google App Engine
Blog: http://googleappengine.blogspot.com
Twitter: http://twitter.com/app_engine
Reddit: http://www.reddit.com/r/appengine



On Thu, Jul 7, 2011 at 6:21 PM, Pol <i...@pol-online.net> wrote:

> Hi,
>
> Assuming the app runs on an HR database and that the number of indexes
> is not a problem:
>
> Say that because of the data model, these queries are equivalent (i.e.
> return the exact same results), which one should be used to get the
> best performance?
>
> query = db.GqlQuery("SELECT * FROM Photo WHERE ANCESTOR IS :1 AND
> prime = TRUE ORDER BY timestamp DESC", self.user.key())
>
> query = db.GqlQuery("SELECT * FROM Photo WHERE ANCESTOR IS :1 AND
> initialized = TRUE AND prime = TRUE ORDER BY timestamp DESC",
> self.user.key())
>
> Does the response change if somewhere else in the code, there is also
> this query (because of shared indexes or something)?
>
> query = db.GqlQuery("SELECT * FROM Photo WHERE ANCESTOR IS :1 AND
> initialized = TRUE ORDER BY timestamp DESC", self.user.key())
>
> Same question, this time with these 2 other queries:
>
> query = db.GqlQuery("SELECT * FROM Photo WHERE event = :1 AND prime =
> TRUE AND hidden = FALSE ORDER BY timestamp DESC", event.key())
>
> query = db.GqlQuery("SELECT * FROM Photo WHERE ANCESTOR IS :1 AND
> event = :2 AND prime = TRUE AND hidden = FALSE ORDER BY timestamp
> DESC", event.key().parent(), event.key())
>
> I understand the 2nd version is an ancestor query which should return
> consistent results (right?) but in this case, it's ok if the results
> are a bit stalled.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to google-appengine@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com.
> 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 google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to