Best practices? get() + markForUpdate() vs getForUpdate()

Is there a performance difference between get() + markForUpdate() vs getForUpdate()?

Is it particularly detrimental to call markForUpdate() many times on the same MObj? (I know it’s not required, I’m asking if it’s “a big deal.”)

Basically, I have lots & lots (let’s say millions – whatever it takes to count as SGS’s vsn of “a lot”) of MRefs, and I’m doing something like:


   For {each item on a list}
      myManagedObject = myManagedReference.get();
      if (myManagedObject.foo() > bar)
         myManagedObject.updateSomeField();

where updateSomeField() is defined as


public void updateSomeField()
{
   markForUpdate();
   field += bar;
}

[EDIT: Note that, in this model, many different updateField_wahtever() calls might result in many calls to markForUpdate()]

and am wondering if I’m going to (eventually) see a performance hit for all those markForUpdate()s. Or is the system designed so that this is a perfectly reasonable way to do things? Or do I need to refactor things to allow me to try to predict which will need updating (I can’t see how I’d do this, right off, but haven’t give it MUCH thought…), and then convert to something like:


   for {each item on list}
       if (it's not going to need updating)
            removeFromList

   for {each item still on list}
       myMO = myRef.getForUpdate();
       myMO.updateField();

where this vsn of updateField() doesn’t have the markForUpdate() in it.

To be honest, the 2nd example grates on my sense of hierarchical ownership of responsibility but, if the first is going to be a major performance hit, I guess I can try to go that way.

What’s the SGS “best practice”, here?

Thanks!

[

Nope. getForUpdate() is basically a convenience method. there is SLIGHLTY more effort in markForUpdate but its on the order of a lookup. Nothing that you should see have any effect on your code.

Nope. No harm in calling it multiple times.

Perfectly reasonable and expected.