Optimized an agent’s runtime from >30 minutes to less than 30 seconds
Julian Buss, May 25th, 2010 17:10:52
Tags:  Development 
I had that agent in one application... the app contains about 300.000 documents, and some of them needs to be checked multiple times a day for events (for example, if they are expired). The agent doing this check needed over 30 minutes to run, and due to agent manager's configuration was always terminated after 30 minutes.

Pretty bad performance, isn't it? Well... not anymore, I'm down to less than 30 SECONDS now, only by re-engineering the logic and one view.

There were several performance killers in that agent, and all of them based on one very common problem: using time/date functions in a view or using the NotesDatabase.search() instead of a ftsearch().

Every Notes dev should know that using time/date functions in a view, either in the select or column formula, is a very bad idea. Granted, there are times where using that technique cannot be avoided, or where this does not cause severe performance problems. But in general, it's a bad idea and if possible, code should be changed so that there is no time/date function used in a view.

In my case, the agent did the following:

1.) Using a NotesDatabase.search() with time/date functions three times (!) to search for a subset of documents, only to remove one item from them.

2.) Refreshing a view which uses multiple time/date functions, then iterating over all documents of that view.

The three NotesDatabase.search() calls alone took 20 minutes or so. Boy, what a bad architecture. Oh, and yes, I have to take all the shame on myself... I wrote that agent some years ago myself. In that time, the application didn't contained many documents, and I was not aware that these techniques could create such a performance problem :-)

So, I managed to remove all NotesDatabase.search() calls and all time/date functions from the view. Now, the agent just iterates over all documents in that view. For every documents some time/date checks are performed and then, when the conditions are met, the event is fired.

The view contains many more documents now, and the agent iterates over many more documents - but still that's WAY faster than before.

Remember: iterating over lots of documents in a view is much faster than using time/date functions in that view.
 
About this site
I am a Lotus Notes developer, consultant and one of the founders of YouAtNotes, a german software vendor specialized in Lotus Notes software for CRM, Workflow and Web solutions.
I write about IBM Lotus software and other stuff which I come across. Have a nice time here!

Search
RSS-Feeds
rssfeed.pngContent Feed
rssfeed.pngComment Feed
Recent posts
Recent comments
Links to YouAtNotes
Links to YouAtNotes (in german)
Archive
Impressum / Datenschutz
(german)