N
nor
Доброе время суток. Некоторое время тому назад я столкнулся с проблемой производительности моего одного проекта, который за последние 12 месяцев значительно возрос в плане функционала и клиентской базы. Начали потупать жалобы от пользователей, что все "тормозит". Пришлось разбирать куски кода "с секундомером в руках", выявлять "слабые звенья" и менять код или логику на более производительные. В результате приложение стало работать значительно быстрее и в целом более стабильнее.
Вот некоторый короткий перечень положений, которыми я руководствовался в процессе этой работы. Надеюсь этот список будет полезен новичкам в Lotus программировании. Приглашаю всех поделиться своими замечаниями и собственными наработками по теме.
- Display images after loading.
- Don't maintain unread marks.
- Optimize document table map.
- Don't overwrite free space.
- Don't support specialized response hierarchy (if there are no responses in a database).
- Use LZ1 compression for attachments.
- Don't allow headline monitoring.
- Soft delete expire time in hours to 48 (if soft deleton is set).
- Limit enrties in $UpdatedBy fields to 25.
- Limit enrties in $Revisions fields to 25.
- Minimize deletion stubs.
- Adjust full-text index options.
- Define Anonymous in the ACL.
- Limit use of 'Strong Encryption'.
- Adjust scheduled agents.
- Do not allow use of stored forms in a database.
- Do not have too many views.
- Remove private views every time when a user closes a db.
- Never use time/date sensitive formulas (selection or column formulas) in views.
- Separate views for end users and for your script.
- Do not complicate a view (avoid complex selection formulas, many categories, many columns, etc.).
- Hidden views should be as simple as possible (no column sorting, no font color, etc.)
- Avoid adding many column sorting arrows to a view.
- Use view.Autoupdate = False in your code every time you retrieve a NotesView object.
- Store the proper computed data in fields on a form to display it in a view rather than making the computation in columns of the view.
- The view set as the default view should be small in size.
- Minimize the use of 'GetView' method of NotesDatabase object.
- Do not use 'Automatically refresh fields' option in a form.
- Use temporary variables as placeholders for data (objects, Notes objects) that is expensive to retrieve.
- Do not put much computed fields on a form.
- Use computed, computed for display and computed when composed fields in proper document modes (new, read, edit).
- Do not use large subforms.
- Avoid large or complex tables on a form.
- Disable AutoReload when using the NotesUIDocument object.
- Avoid using Computed and Computed when Composed fields to format fields for display purposes. Use the “Computed for Display” type for fields which are only
used to format data for the UI.
- When many fields in a form contain formulas that evaluate on the same event, it is recommended that a script event be created to replace all the field
formulas.
- Minimize the use of complex pop-ups within a form.
- Use buttons and picklists instead of drop-down lists when using @DbLookup and @DbColumn formulas.
- Pay attention to 'Cache' and 'Nocache' parameters of @DbLookup and @DbColumn formulas.
- Use one lookup to get multiple fields using @DbLookup and @DbColumn formulas.
- Use column numbers instead of field names in @DbLookup and @DbColumn formulas.
- Make use of the @IsDocBeingEdited and @IsDocumentBeingSaved functions to improve keyword lookup formulas.
- Keyword fields and pop-ups utilizing lookups all evaluate when a document is being opened. To reduce document opening time, place
lookups behind buttons. Button formulas only evaluate when selected.
- Use temporary variables in your formula to save @Db lookup results.
- Use temporary fields (computed for display) in your form to save @Db lookup results.
- Combine required data into one column. Use the @Subset function to parse the results.
- Generally use view.GetAllDocumentsByKey (view.GetDocumentByKey) and db.Search to retrieve a document collection.
- Use the StampAll and RemoveAll methods of NotesDocumentCollection to process a collection of documents.
- Use GetNextDocument instead of GetNthDocument of NotesDocumentCollection object.
- Generally use the For and Forall loops.
- Do not use dynamic arrays so much.
- Do not use an array or list of NotesDocument objects.
- Do not use environment variables.
- Don't Use 'Print' so much.
- Declare your variables.
- Resume out of your error handling blocks.
- Resize arrays infrequently.
- Use variant types only when required.
- Minimize the use of Redim.
- Use back-end objects instead of front-end objects.
- Reuse existing objects, do not repeat them again.
- Do not use 'Arrayappend' method so mach ('Redim Preserve' is MUCH more efficient than many calls to 'ArrayAppend').
- Generally use 'GetDocumentByUNID' method of NotesDatabase object to retrieve a document.
- When accessing a field more than once, get the item once and cache it in a NotesItem variable.
Вот некоторый короткий перечень положений, которыми я руководствовался в процессе этой работы. Надеюсь этот список будет полезен новичкам в Lotus программировании. Приглашаю всех поделиться своими замечаниями и собственными наработками по теме.
- Display images after loading.
- Don't maintain unread marks.
- Optimize document table map.
- Don't overwrite free space.
- Don't support specialized response hierarchy (if there are no responses in a database).
- Use LZ1 compression for attachments.
- Don't allow headline monitoring.
- Soft delete expire time in hours to 48 (if soft deleton is set).
- Limit enrties in $UpdatedBy fields to 25.
- Limit enrties in $Revisions fields to 25.
- Minimize deletion stubs.
- Adjust full-text index options.
- Define Anonymous in the ACL.
- Limit use of 'Strong Encryption'.
- Adjust scheduled agents.
- Do not allow use of stored forms in a database.
- Do not have too many views.
- Remove private views every time when a user closes a db.
- Never use time/date sensitive formulas (selection or column formulas) in views.
- Separate views for end users and for your script.
- Do not complicate a view (avoid complex selection formulas, many categories, many columns, etc.).
- Hidden views should be as simple as possible (no column sorting, no font color, etc.)
- Avoid adding many column sorting arrows to a view.
- Use view.Autoupdate = False in your code every time you retrieve a NotesView object.
- Store the proper computed data in fields on a form to display it in a view rather than making the computation in columns of the view.
- The view set as the default view should be small in size.
- Minimize the use of 'GetView' method of NotesDatabase object.
- Do not use 'Automatically refresh fields' option in a form.
- Use temporary variables as placeholders for data (objects, Notes objects) that is expensive to retrieve.
- Do not put much computed fields on a form.
- Use computed, computed for display and computed when composed fields in proper document modes (new, read, edit).
- Do not use large subforms.
- Avoid large or complex tables on a form.
- Disable AutoReload when using the NotesUIDocument object.
- Avoid using Computed and Computed when Composed fields to format fields for display purposes. Use the “Computed for Display” type for fields which are only
used to format data for the UI.
- When many fields in a form contain formulas that evaluate on the same event, it is recommended that a script event be created to replace all the field
formulas.
- Minimize the use of complex pop-ups within a form.
- Use buttons and picklists instead of drop-down lists when using @DbLookup and @DbColumn formulas.
- Pay attention to 'Cache' and 'Nocache' parameters of @DbLookup and @DbColumn formulas.
- Use one lookup to get multiple fields using @DbLookup and @DbColumn formulas.
- Use column numbers instead of field names in @DbLookup and @DbColumn formulas.
- Make use of the @IsDocBeingEdited and @IsDocumentBeingSaved functions to improve keyword lookup formulas.
- Keyword fields and pop-ups utilizing lookups all evaluate when a document is being opened. To reduce document opening time, place
lookups behind buttons. Button formulas only evaluate when selected.
- Use temporary variables in your formula to save @Db lookup results.
- Use temporary fields (computed for display) in your form to save @Db lookup results.
- Combine required data into one column. Use the @Subset function to parse the results.
- Generally use view.GetAllDocumentsByKey (view.GetDocumentByKey) and db.Search to retrieve a document collection.
- Use the StampAll and RemoveAll methods of NotesDocumentCollection to process a collection of documents.
- Use GetNextDocument instead of GetNthDocument of NotesDocumentCollection object.
- Generally use the For and Forall loops.
- Do not use dynamic arrays so much.
- Do not use an array or list of NotesDocument objects.
- Do not use environment variables.
- Don't Use 'Print' so much.
- Declare your variables.
- Resume out of your error handling blocks.
- Resize arrays infrequently.
- Use variant types only when required.
- Minimize the use of Redim.
- Use back-end objects instead of front-end objects.
- Reuse existing objects, do not repeat them again.
- Do not use 'Arrayappend' method so mach ('Redim Preserve' is MUCH more efficient than many calls to 'ArrayAppend').
- Generally use 'GetDocumentByUNID' method of NotesDatabase object to retrieve a document.
- When accessing a field more than once, get the item once and cache it in a NotesItem variable.