IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

For performance reasons, it's generally smart to set NotesView.AutoUpdate = False to prevent LotusScript from constantly "refreshing" the view internally whenever it notices there's a document change (which, if your agent is modifying every document in the view, can happen a lot). Even if you're saving documents that aren't in the specific view, it saves time if LotusScript doesn't have to continually check whether the recently modified document is in the view.

However, yesterday I found another reason to use this property, unrelated to performance. It seems that if you use a NotesViewNavigator, and the view you got it from does not have AutoUpdate=False, the NotesViewNavigator can fail to get the next document (with the message "Entry not found in index", referring to a NotesViewEntry object). I've only seen this happen if the entry is a category, but I'm not sure it's the only case where it happens. Even though I was only reading documents, someone else changed a document on the server, this caused the view to update, and the NotesViewEntry object became invalid.

This is a sneaky problem. It's not going to happen when you're testing the agent with nobody else using the application. Code defensively -- use view.AutoUpdate=False routinely.

Andre Guirard | 7 February 2008 08:41:07 AM ET | Man-cave, Plymouth, MN, USA | Comments (7)


 Comments

1) I had the same problem today
Jens Winkelmann | 2/7/2008 7:33:23 PM

I had no idea why my agent runs perfect local on my computer but always breaks with an error on our productive database on the server.

Then I found this documents

{ Link }

{ Link }

That cost me half a day

2) What I find a little annoying ...
Harkpabst Meliantrop | 2/8/2008 2:17:01 AM

... about this one, is the APAR fix status:

Resolved (???) as: No Plans To Fix EVER (or so)

Setting AutoUpdate to false might well be considered a best practice when using any code that walks a view in any way, but given the fact, that there isn't even the slightest hint in Designer help, despite the fact that this issue has been known (by IBM, not me) for years ...

3) Why doesn’t AutoUpdate default to False?
Brandt S Fundak | 2/8/2008 10:11:29 AM

Since there usually seems to be more benefit to setting AutoUpdate to false rather than leave it as the default, what is the rationale behind setting AutoUpdate to true by default? Is it because AutoUpdate allows the backend view to behave as we would expect a view in the UI to behave? I really can't think of a better reason.

4) re: Why doesn’t AutoUpdate default to False?
Andre Guirard | 2/8/2008 3:20:17 PM

Possibly it was a poor choice of default value at the time the property was first implemented, but if we change it now, it's likely to break applications. This is the sort of thing that we can address by static analysis tools, which I hope people will create using DXL. Something cheap or free to help novice developers, would be super. If you could set something up to execute on save of a design element and automatically run some tests on it, that would be outstanding. It could certainly be done manually via a Tools menu entry.

5) What does this do with respect to multiple threads reading the view?
Erik Brooks | 2/8/2008 7:11:49 PM

I've got a suspicion that AutoUpdate=False causes semaphore locks to be placed on your view until the thread that set AutoUpdate=False is done with the view.

I haven't done enough research to confirm this, but I was recently discussing another PMR with Lotus Support and they couldn't answer my question off the top of their head either: What happens with regards to multiple threads accessing a view where one sets AutoUpdate=False?

If I have a 10 MB view index, and I set AutoUpdate=False, what exactly happens on the backend? I would assume it's one of two things:

1. The thread setting AutoUpdate=False gets its own in-memory copy of the view index as it exists at that moment in time. This will temporarily consume some disk resources to read the index, and will also consume 10MB of memory until this thread releases the view. Other threads accessing the view will see the index as it exists at that moment for them, and they can then set AutoUpdate=False on their own if they wish (getting their own 10MB copies of the index).

2. AutoUpdate=False causes a semaphore read lock to be placed on the view until the calling thread releases the view. This means that other threads that are asking to read the view will queue until the original thread is done. In addition, no writes can take place to the view until the thread is finished.

Can you tell us what the true behavior is, Andre? I've got a bizarre performance problem (ND7) that seems semaphore-related, and I'm pretty sure that this it's somehow related to AutoUpdate=False.

6) Another reason to set AutoUpdate = False
Morten Clausen | 3/3/2008 3:33:29 PM

I would assume 1) as 2) is enormously destructive. It would mean that one client could bring a server to a screeching halt by simply acquiring a view like ($ServerAccess) in names.nsf, setting this option and doing something for 20 minutes. :-)

I would also assume that 1) meant that an in-memory version of the view index created for a session was de-coupled from the server's primary version so that Autoupdate = False simply means "do not tell me about changes to this view". At least, that's how it looks when using the option. Occams Razor and all that...

7) Agent takes too long
Nishanth Kathyarath | 9/16/2014 8:58:51 AM

when a specific scheduled agent was running 7.0.3, it was taking 10 mins. When it's migrated 8.5.3 , it started taking hours, not completed even after 6 hours. We tried everything possible, nothing resolved. Finally identified that the method GETALLDOCUMENTSBYKEYs was taking up 99.5% of the time. Hence IBM suggested to set the NotesView.AutoUpdate = False, now the agent is executing in 2 minutes. When I set it back to true, it runs forever. This is on a 3 GB database.I however do not know the downside/ impact of setting this to false.

8) SPR SPR # CSAO88359U
Andre Guirard | 9/16/2014 9:11:51 AM

Nishanth, this issue was supposedly fixed in 8.5.3. Can you confirm the version?

 Add a Comment
Subject:
   
Name:
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     Cancel

Search this blog 

Disclaimer 

    About IBM Privacy Contact