Events and performance
When creating AL extensions, it’s extremely important to think about the extensibility of your solution. In Chapter 3, Extension Development Fundamentals, and Chapter 4, Developing a Customized Solution for Dynamics 365 Business Central, we saw that we need to use events to write an extensible solution. But can events impact performance?
In general, a publisher (who raises the event) has no impact on performance.
Event subscribers could instead affect performance.
If you write logic attached to a table event (OnInsert
, OnModify
, and so on) remember that the runtime will issue SQL update/delete statement rows in a for
loop rather than in a single SQL statement. As said before, remember also that bulk operations are impacted if you have events subscribing to the table events, and these operations are converted to normal single SQL operations.
As a best practice, you should handle events in a single instance codeunit if possible, and the...