Performance basics for IBM Lotus Notes developers – Some additions?

Andre Guirard wrote a nice interesting piece of document regarding considerations for application development. The document you can download here.

Recently I have asked to write down some ‘best practices’ from a developer perspective. I see a lot of Andre’s writing return in this, also since most of my work was ‘just’ a collection of documents / papers / hints & tips I have collected the past years.

I will wrote some additional performance considerations which I did not find back in Andre’s work:

Use @trim in all translation events for fields type text, this avoids that you later have to use it in view columns

@Trim(@ReplaceSubstring(@ThisValue; @Char(9):@Newline; ” “))

—-

Make sure when using subforms something is written in Globals of the subform, it dus not matter what (Notes only)

Dim loadfaster As Integer
loadfaster =True

The more subforms you have the more effect code in Globals has.

—-

Don’t use “Print” so much (LotusScript)

Minimize the use of the Print statement when performing actions in long loops. Printing a lot of messages to the status bar or console uses a surprising amount of memory, and it can have a noticible impact on an otherwise fast-running loop. Specifically, the memory used by each Print statement is not released until the entire agent is finished.

—-

Avoid large or complex tables

Large or complex tables can greatly affect the speed with which a form can be rendered (both in the client and in the browser). In particular, avoid tables with a huge number of rows, a lot of nesting, or a large number of hide-when conditions.

—-

For agents: avoid Reader fields when possible

Using Reader fields can slow down all of your document processing code across the board, because the database has to evaluate the reader fields for each document before it can even attempt to do anything with them. This is especially true when the agent signer doesn’t have access to a large number of documents in the database, because the documents that aren’t visible still have to be evaluated before they can be skipped.

—-

Share NotesView References

If you need to use a reference to a view multiple times in your code, get the view only once and share the reference (either using a global or static variable, or by passing a NotesView object as a parameter in functions/subs/methods). Accessing views using getView is a very expensive operation.

—-

Use @Function Agents For Simple Document Modifications

If you just need to modify, add, or delete one or several [non rich-text] fields in all or selected documents in a view, it is much faster to use an agent with simple @Functions (rather than LotusScript or Java) that runs against all or selected documents. 

—-

Resize Arrays Infrequently

ReDim your arrays as infrequently as possible. However, if you have to append data to an array quite often, Redim Preserve is MUCH more efficient than many calls to ArrayAppend

Default view

Whenever your application is opened, your default view is opened. Always be sure that this is a view that opens quickly.

—-

Use buttons and picklists instead of drop-down lists

In some cases, there are so many drop-down lists, and they’re so large and used so frequently, that the only reasonable solution is to stop using them on the main form. The line of reasoning to use is to ask yourself the following questions:

  • How many times will a document be read in its life?
  • How many times will a document be edited?
  • Of the times it’s edited, how many times will these lookups be required?

—-

Use DigestSearch Method

For searching server-based databases from a Notes client, DigestSearch is twice as fast as any other search method available, outperforming both full-text search and LotusScript’s GetDocumentByKey method. You call DigestSearch using this LotusScript command:

Set doc=FastSearchByKey(db, “searchword”)

Like I said before, this is ‘collected work’ so I take no responsibility if it would not increase performance. See it as food for thought =)

Advertisements

5 thoughts on “Performance basics for IBM Lotus Notes developers – Some additions?

  1. Nathan T. Freeman 2008-May-18 / 12:31 am

    Patrick, it would be wise to mention that DigestSearch is a 3rd party tool, and is not NEARLY as simple as writing FastSearchByKey. One must actually implement Andrei’s DigestSearch infrastructure.

  2. quintessens 2008-May-18 / 5:52 pm

    Hej Julian

    yes some items might come from the nsftool website. I can not recall the source where I copied the information from…

  3. mikle 2008-May-19 / 11:13 am

    Thanks for the post! notes was freezing when opening a form with more then 14 subforms…

    decided to go for subforms to simplify the hide formulas for various sections in the document…

    Any idea why code in the globals makes such a big difference?

    Mike

  4. Rob 2008-May-31 / 8:40 pm

    On thing that has bit me several times is multiple spaces embedded in a string. All web browsers eliminate multiple white space characters and return just one. In a selection box or check-boxes that come from a formula if the items contain more than one space in a row, the browser returns a value that does not match the one sent.

    I wish the @trim function had a switch that would cause it to trim out redundant white space. As it is I have to write using @replacesubstring similar to what you have above.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s