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

Joseph LeMay writes:

...each contract has change orders associated with it.  Each change order has to show the amount of the original contract plus all previous change orders, and then the new total, so there's some math to do on each change order, and the more change orders you have, the more math there is.  So what I'd have to do is
set dc = view.GetAllDocumentsByKey(ContractNo)
then loop through the dc by accessing the properties of each document.
But would I get a peformance kick if I did
set viewnav = view.createViewNavFromCategory(ContractNo)
then looped through the view entries?

My answer (and I'm sure someone will correct me if I'm wrong, given the crowd who read this), neither one is significantly more efficient. The performance hit is in the next step, where you retrieve the data. If you use the Columnvalues property to get data from the view, then you're in good shape. If you use NotesDocument.GetItemValue or NotesDocument.fieldname, it takes longer because you have to "crack open" the note rather than just pulling the information from the view table. So use Columnvalues.
To improve performance further, try to avoid iterating through the view entries. In your case, you might be able to do this by taking advantage of category totals. Since a category row is a NotesViewEntry also, you should be able to use the NotesView methods to retrieve the first document row that matches your key, then back up an entry to find the category row. So long as you only get one change order at a time in any given execution of your code, you can get the current total very quickly this way. Even if you get more than one, assuming the documents are sorted properly withing the categories, you should be able to jump to the most recent CO, update it based on the total, then subtract its own figure from the total and move on to the next document, etc as long as you keep finding unprocessed orders.

Andre Guirard | 11 October 2007 11:13:38 PM ET | Plymouth, MN, USA | Comments (2)

Search this blog 


    About IBM Privacy Contact