Use Database Wait Statistics

Completed

Developers and administrators can get insights into database performance.

The database for a Business Central environment makes performance counters and information about SQL queries available through Dynamic Management Views (DMVs). It requires direct database access to be able to obtain this information, and for Business Central online environments, this isn't possible due to security restrictions.

With this capability, the Business Central platform makes data about database wait statistics as a virtual table, so that the data can be accessed from AL code. We'll also add a page on top of the new table to make it easy to get the data without having to write code.

You can check the performance of your database by looking at the information provided by Database Wait Statistics in Business Central.

Screenshot of database wait statistics.

You can see how long the previous queries had to wait with the wait type indicating the reason of the wait. The wait times give you a quick idea about the database performance and where it can be optimized.

There can be different reasons for a query to wait, for example, a query can wait for a resource that isn't free or the wait can be because of a queue. For details about the types of wait in SQL database, see Types of Waits.

The Database Wait Statistics presents a table with information divided into these types of columns:

  • Wait category type, which states reasons for a query to wait. For example, CPU, Idle, Lock, Buffer IO, and so on. For more information about these objects, see SQL Server, Wait Statistics Objects.

  • Different wait time counters, for example, Wait Time in ms, Max Wait Time in ms, and Signal Wait Time in ms.

  • Waiting tasks count shows the total count of each wait category that has happened.

  • Database start time indicates the time when database was first started or is restarted.

The wait times aren't live. These statistics show the wait times for the queries, which are completed from the time the database was started or when it was reset.

You can also emit this data to telemetry and can analyze it in Application Insights. To do this, choose the Emit telemetry icon from the tab.