Friday, 17 April 2015

Caching display methods

A display method is usually used to fetch data from another source or to perform calculations. It is recommended to create them on Tables. Once these display methods are used on forms, these are called every time the form is re-drawn. However if the field/group/tab which uses this method is hidden the display method is not called. For performance reasons the display method should be cached. This way system calls the method once and stores its values reducing unnecessary calls to server.

Recently we had a performance issue and on investigation found out that apart from the actual cause of problem, some display methods are not cached. So we followed the recommendations and cached the methods using attribute [SysClientCacheDataMethodAttribute(true)].

Every thing was fine until a user complained about performance using a specific customer. We investigated again and found out that one of the display method that we cached in previous findings is causing the issue. It had a IF condition and was doing some heavy calculation in certain cases only. But why this was not a problem before. On further investigation we found that the field on form which was using this display method was hidden. So when the display method was not cached it was not called by system.

However after caching it, upon opening of the form, system was calling the following method
<Table Name>::executeCachedDisplayMethods
This method was calling all the cached display methods of the table regardless of whether the field for the display method is hidden or not. This behavior is different from when the display method is not cached.

Our solution to problem was to remove the hidden field from the form.

This posting is provided "AS IS" with no warranties. Use code at your own risk.

No comments:

Post a Comment