The datastore will only update indexes that changed, so if s didn't change you would only be charged 1 write op for the entity write (vs 0 write ops if you didn't call put at all). I believe the dev_appserver only shows the cost for inserting a new entity (which is substantially different from the cost of an update).
On Wed, Jun 6, 2012 at 1:16 PM, mac <macwa...@gmail.com> wrote: > Hi Alfred, > > Sorry for bringing this old topic back, I am also confused by the number > showed in the dev_appserver. > > I think you meant > 1 op for the entity > 2x2 = 4 ops for each changed index value (1 remove, 1 add and two > directions) > > My question is, do we need to do checks before calling put() to make sure > it won't update all fields and their indices? > > For example, do we need to do something like below? > > s = Sample.all().get()[0] > changed = False > > if s.field1 != field1_new_value: > s.field1 = field1_new_value > changed = True > > if s.field2 != field2_new_value: > s.field2 = field2_new_value > changed = True > > if s.field3 != field3_new_value: > s.field3 = field3_new_value > changed = True > > if changed: > s.put() > > Or we can just do below. > s = Sample.all().get()[0] > s.field1 = field1_new_value > s.field2 = field2_new_value > s.field3 = field3_new_value > s.put() > > And datastore will check which fields were changed, only update those > fields and their indices? > > > On Saturday, September 24, 2011 1:00:44 PM UTC-7, Alfred Fuller wrote: >> >> Yes, the write ops for changing an entity depends on how many indexed >> properties you change. It is: >> 1 op for the entity >> 2 ops for each changed index value (1 to remove the old value and 1 to >> add the new) >> >> Since it is not a fixed value and depends on what you actually modify, we >> do not (can not) show it in the dev_appserver's Datastore Viewer. >> > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/google-appengine/-/aqIb5sFqOfsJ. > > 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.