Hi,
I'm using the code below from Nicks' blog (
http://blog.notdot.net/
2010/01/ReferenceProperty-prefetching-in-App-Engine).
Everything works as expected locally, I can see one request in /_ah/
stats for getting 100 items. However when I run the same code on
Production, I can see this method getting called 100 times in /_ah/
stats and can see my database read allocation decrease very quickly.
Am I missing something with the setup, or is there a difference in
behaviour between local and production?
Thanks
Chris
def prefetch_refprops(entities, *props):
fields = [(entity, prop) for entity in entities for prop in props]
ref_keys = [prop.get_value_for_datastore(x) for x, prop in fields]
ref_entities = dict((x.key(), x) for x in db.get(set(ref_keys)))
for (entity, prop), ref_key in zip(fields, ref_keys):
prop.__set__(entity, ref_entities[ref_key])
return entities