Upravit

Sdílet prostřednictvím


sys.resource_usage (Azure SQL Database and Azure SQL Managed Instance)

Applies to: Azure SQL Database Azure SQL Managed Instance

Important

This feature is in a preview state. Do not take a dependency on the specific implementation of this feature because the feature might be changed or removed in a future release.

While in a preview state, the Azure SQL Database operations team might turn data collection off and on for this DMV:

  • When turned on, the DMV returns current data as it is aggregated.
  • When turned off, the DMV returns historical data, which might be stale.

Provides hourly summary of resource usage data for user databases in the current server. Historical data is retained for 90 days.

For each user database, there is one row for every hour in continuous fashion. Even if the database was idle during that hour, there is one row, and the usage_in_seconds value for that database will be 0. Storage usage and SKU information are rolled up for the hour appropriately.

Columns Data Type Description
end_time datetime Time (UTC) in hour increments.
database_name nvarchar Name of user database.
sku nvarchar Name of the service tier. Possible values include: Basic, Standard, Premium, GeneralPurpose, BusinessCritical, Hyperscale.
storage_in_megabytes decimal Maximum used storage size for the hour, including database data, indexes, stored procedures and metadata.

Permissions

Requires permission to access the master database on the logical server in Azure SQL Database.

Examples

The following query returns data from the past two days:

SELECT end_time, database_name, sku, storage_in_megabytes 
FROM sys.resource_usage
WHERE end_time > DATEADD(dd,-2,SYSDATETIME());
GO

Next steps

Learn more about Azure SQL Database in the following articles: