編輯

共用方式為


DataAccessIntent Property

Version: Available or changed with runtime version 5.0.

Sets the data access intent of the page.

Applies to

  • Page
  • Report
  • Query

Property value

Value Available or changed with Description
ReadOnly runtime version 5.0 Intent to access records, but not to modify them. Read-only pages are run against a replica of the database leading to improved performance, but preventing modifications to the database records.
ReadWrite runtime version 5.0 Intent to access and modify records.

Syntax

DataAccessIntent = ReadOnly|ReadWrite;

Remarks

For reports, API pages, and API queries, the Business Central server can use read-only database replicas on Azure SQL Database and SQL Server. If replicas are enabled, use this property to reduce the load on the primary database. Using ReadOnly might also improve performance when viewing objects. ReadOnly works as a hint for the server to route the connection to a secondary (read-only) replica, if one is available. When a workload is executed against the replica, insert/delete/modify operations aren't possible. If any of these operations are executed against the replica, an exception is thrown at runtime. The following sections explain how this property is handled on different object types.

Page

The property only applies to pages of type API. The Editable property must be set to false. When an OData call fetches data from the page, then it's only the call to fetch the data that uses the read-only replica. Database calls needed in setting up the API page are performed against the primary database, for example, database calls in the OpenCompany triggers.

Query

The property only has an effect on queries exposed through OData (API queries). It has no effect in normal code paths. When an OData call fetches data from the query, then it's only the call to actually fetch the data that uses the read-only replica. Database calls needed in setting up the session before retrieving data are performed against the primary database, for example, database calls in the OpenCompany triggers.

Report

The property also affects reports generated in UI sessions. The database calls needed while iterating through data items use the read-only replica if it's set. Records read before and after generation of the data set are read from the primary database.

From the client, the property value can be overwritten by using page 9880 Database Access Intent List page.

When calling an API page or API query, the property value can be overwritten by specifying HTTP request header Data-Access-Intent.

Note

Setting the DataAccessIntent property to ReadOnly doesn't guarantee that your data access will be running on the secondary replica. It's merely stating that the code only requires read ability, so a read-only connection can be used.

For example, the property doesn't apply to queries running at arbitrary times during normal AL execution (that is, the server doesn't change to ReadOnly mode in the middle of a transaction). So for queries, the property only fully applies when they're exposed as an API/OData feed directly.

Using Read Scale-Out for Better Performance
Optimizing SQL Server Performance
Properties
Page Properties
Specifying Data Access Intent for REST API GET requests