Performance gain by reducing locks in the database

Important

This content is archived and is not being updated. For the latest documentation, go to What's new or changed in Business Central. For the latest release plans, go to Dynamics 365, Power Platform, and Cloud for Industry release plans.

Enabled for Public preview General availability
Admins, makers, marketers, or analysts, automatically Sep 8, 2023 Oct 2, 2023

Business value

We will minimize the use of database locks when running business logic. This will benefit all usage scenarios, both for web service integrations, background jobs, and interactive sessions.

Feature details

Data stack optimization

We changed the default locking behavior in AL for subsequent data modifications on the same table in the same session. Previously, the default locking behavior was UpdLock, which meant that the session would acquire an update lock on data from the table until it committed or rolled back its changes. This could cause blocking and contention issues when multiple sessions tried to access or modify the same table.

Locking behavior before

Now, the default locking behavior is ReadCommitted, which means that the session will release the exclusive lock after each data modification and only acquire a shared lock when reading data. This allows other sessions to read and write to the same table concurrently, as long as they don't conflict with each other's changes. This improves the throughput and responsiveness of your online service and reduces the likelihood of deadlocks and timeouts.

Locking behavior with tri-state locking

Who benefits

This improvement benefits all users of Business Central, especially those who have large or complex datasets or who perform frequent or intensive data operations on their online service. You'll notice a faster and smoother experience when using Business Central and fewer errors or interruptions due to locking issues.

How to use

With new environments created on version 23.0 and later, you don't need to do anything to enable this improvement; it will be turned on by default in version 23.0. For existing environments, the feature is available but turned off by default. If you have any custom code or extensions, there's a possibility that it may require some adjustments to adopt the new locking behavior. Therefore, we recommend that you verify this change. You can do so by copying the production environment into a sandbox and turning on the feature in the sandbox from the Feature Management page. Once you've turned on the feature, test, review, and adjust the code if needed. When all tests pass, you can turn the new locking behavior feature on in your production environments as well to obtain better performance and throughput gains.