简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM