Google App Engine (Python) slow ancestor queries
I am using appstats to debug some important queries in our app. One thing I noticed is that for a particular entity kind, an ancestor query is many times slower than a non-ancestor query.
When I go from:
q = Entity.query(ancestor=ancestor_key)
q = q.filter(Entity.field == 'foo')
return q.fetch(10)
to:
q = Entity.query()
q = q.filter(Entity.field == 'foo')
return q.fetch(10)
In the development environment, the first query always takes more than 500 ms and often above 1 second while the second one takes 20-100 ms. All the right indexes are in place and nothing else is running at the same time as the queries.
Any ideas?
The dev_appserver is an emulation of the real thing. It can't behave in the same way. Don't worry about stuff like this unless it's also a problem when deployed.
链接地址: http://www.djcxy.com/p/23224.html上一篇: 数据存储获取VS获取(键