Control database locking behavior

Important

This content is archived and is not being updated. For the latest documentation, go to What's new and planned for Dynamics 365 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 Mar 1, 2023 Apr 1, 2023

Business value

Database locking is one of the main root causes for performance issues. When AL code takes fewer locks, it increases the performance of the system for users.

Feature details

By default, the runtime of Business Central automatically determines the isolation levels used when querying the database. AL developers can now explicitly control the database isolation level on individual reads on a record instance.

A new ReadIsolation method has been introduced on the record data type. The method has the following syntax:

rec.ReadIsolation := IsolationLevel::<enum value>

The method can also be invoked using property access syntax.

The following table describes the possible IsolationLevel values:

Value Description
Default Follows the table's isolation level for reads; same behavior as not setting an IsolationLevel.
ReadCommitted Allows reads on committed data only; not data that's been modified by other transactions but not yet committed.
ReadUncommitted Allows the record to read data that has been modified by other transactions but not yet committed (also called dirty reads). A ReadUncommitted transaction takes no locks and ignores locks from other transactions.
RepeatableRead Ensures that reads stay stable for the life of the current transaction. Until the current transaction completes, the record can't read data that has been modified but not yet committed by other transactions and other transactions can't modify data that has been read by the current transaction.
UpdLock Ensures that reads stay consistent for the life of the current transaction. Until the current transaction completes, the record can't read data that has been modified but not yet committed by other transactions and other transactions with the same isolation level can't read data that was read by the record.

See also

Record instance isolation level (docs)