how about batch update using db.put()?

following is extracted from
http://googleappengine.blogspot.com/2009/06/10-things-you-probably-didnt-know-about.html


For example, take a look at this common pattern:

for entity in MyModel.all().filter("color =",
    old_favorite).fetch(100):
  entity.color = new_favorite
  entity.put()


Doing the update this way requires one datastore round trip for the
query, plus one additional round trip for each updated entity - for a
total of up to 101 round trips! In comparison, take a look at this
example:

updated = []
for entity in MyModel.all().filter("color =",
    old_favorite).fetch(100):
  entity.color = new_favorite
  updated.append(entity)
db.put(updated)

By adding two lines, we've reduced the number of round trips required
from 101 to just 2!



- eric


2010/1/14 Patrick Twohig <patr...@namazustudios.com>:
> So I'm looking at trying to reset large amounts of data en masse.  Say I
> want to reset a counter on every account each week, how would I go about
> implementing something like that?  Would I have to go through each object,
> update it, and store it?  If that's the case, how do I go about doing so
> without killing my quota or running up my usage extremely high?
>
> Thanks,
> Patrick.
>
> --
> 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-appeng...@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-appeng...@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