Common Plugins Performance Mistakes

December 9, 2012

no comments

I have been conducting few code review session for my customers recently.

When reviewing Plugins, I have noticed some Plugins Steps are registered to a message, such as Create, but without specifying a Primary Entity. This means such Plugin Step is triggered for all entities (existing end new) record creation. It also means the Plugin code must suit all entities or filter specific entities to operate upon.

Unless such Plugin is actually relevant to any Create operation for any entity, this approach negatively impacts the application performance. Although Plugins are cached, launching a Plugin is an expensive operation, especially in large scales.

A better approach would be to register the Plugin Step for the Create message only for relevant entities. This will eliminate the need to filter relevant entities in code and trigger the Plugin step only when it is actually required.

Another common mistake I spotted is related to the Update message. When specifying the Update message, the Plugin Registration Tool allows you to specify entity attributes which update will trigger the Plugin Step. If you don’t specify these attributes, updating any of the entity attributes will trigger the Plugin step and cause redundant and expensive Plugin launching. 

Plugin Update Attributes Selection

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>