sys.resource_stats (Azure SQL Database)sys.resource_stats (Azure SQL Database)

適用範圍:Applies to: 是Azure SQL DatabaseAzure SQL DatabaseYesAzure SQL DatabaseAzure SQL Database 是Azure SQL 受控執行個體Azure SQL Managed InstanceYesAzure SQL 受控執行個體Azure SQL Managed Instance適用範圍:Applies to: 是Azure SQL DatabaseAzure SQL DatabaseYesAzure SQL DatabaseAzure SQL Database 是Azure SQL 受控執行個體Azure SQL Managed InstanceYesAzure SQL 受控執行個體Azure SQL Managed Instance

傳回 Azure SQL Database 的 CPU 使用量和儲存體資料。Returns CPU usage and storage data for an Azure SQL Database. 於五分鐘間隔內收集及彙總資料。The data is collected and aggregated within five-minute intervals. 針對每個使用者資料庫,每隔五分鐘的報告視窗都會有一個資料列,其中資源耗用量有變更。For each user database, there is one row for every five-minute reporting window in which there is a change in resource consumption. 傳回的資料包含 CPU 使用量、儲存體大小變更和資料庫 SKU 修改。The data returned includes CPU usage, storage size change, and database SKU modification. 沒有變更的閒置資料庫在每隔五分鐘的間隔內可能不會有資料列。Idle databases with no changes may not have rows for every five-minute interval. 歷程記錄資料大約會保留 14 天。Historical data is retained for approximately 14 days.

Sys.resource_stats view 具有不同的定義,這取決於與資料庫相關聯的 Azure SQL Database 伺服器版本。The sys.resource_stats view has different definitions depending on the version of the Azure SQL Database Server that the database is associated with. 請考慮這些差異,以及升級到新伺服器版本時應用程式所需的任何修改。Consider these differences and any modifications your application requires when upgrading to a new server version.

下表描述 v12 伺服器中可用的資料行:The following table describes the columns available in a v12 server:

資料行Columns 資料類型Data Type 描述Description
start_timestart_time datetimedatetime UTC 時間,表示5分鐘報告間隔的開始時間。UTC time indicating the start of the five-minute reporting interval.
end_timeend_time datetimedatetime 指出五分鐘報告間隔結束的 UTC 時間。UTC time indicating the end of the five-minute reporting interval.
database_namedatabase_name nvarchar(128)nvarchar(128) 使用者資料庫的名稱。Name of the user database.
skusku nvarchar(128)nvarchar(128) 資料庫服務層。Service Tier of the database. 以下是可能的值:The following are the possible values:

基本Basic

標準Standard

PremiumPremium

一般用途General Purpose

業務關鍵Business Critical
storage_in_megabytesstorage_in_megabytes floatfloat 時間週期的最大儲存體大小(以 mb 為單位),包括資料庫資料、索引、預存程式和中繼資料。Maximum storage size in megabytes for the time period, including database data, indexes, stored procedures, and metadata.
avg_cpu_percentavg_cpu_percent **decimal (5,2) **decimal(5,2) 平均運算使用率,以服務層限制的百分比計算。Average compute utilization in percentage of the limit of the service tier.
avg_data_io_percentavg_data_io_percent **decimal (5,2) **decimal(5,2) 根據服務層限制,計算平均 I/O 使用率的百分比。Average I/O utilization in percentage based on the limit of the service tier. 針對超大規模資料庫,請參閱 資源使用量統計資料中的資料 IOFor Hyperscale databases, see Data IO in resource utilization statistics.
avg_log_write_percentavg_log_write_percent **decimal (5,2) **decimal(5,2) 平均寫入資源使用率,以服務層限制的百分比計算。Average write resource utilization in percentage of the limit of the service tier.
max_worker_percentmax_worker_percent **decimal (5,2) **decimal(5,2) 並行工作者 (要求的最大值會根據資料庫服務層級的限制,) 以百分比表示。Maximum concurrent workers (requests) in percentage based on the limit of the database's service tier.

根據並行背景工作計數的15秒樣本,最大值目前是以五分鐘的間隔計算。Maximum is currently calculated for the five-minute interval based on the 15-second samples of concurrent worker counts.
max_session_percentmax_session_percent **decimal (5,2) **decimal(5,2) 並行會話的數目上限,以百分比為單位,以資料庫的服務層級為基礎。Maximum concurrent sessions in percentage based on the limit of the database's service tier.

根據並行會話計數的15秒樣本,最大值目前是根據五分鐘的間隔進行計算。Maximum is currently calculated for the five-minute interval based on the 15-second samples of concurrent session counts.
dtu_limitdtu_limit intint 此間隔期間,此資料庫目前的最大資料庫 DTU 設定。Current max database DTU setting for this database during this interval.
xtp_storage_percentxtp_storage_percent **decimal (5,2) **decimal (5,2) 記憶體內部 OLTP 的儲存體使用量,以服務層的限制百分比為單位, (在報告間隔結束時) 。Storage utilization for In-Memory OLTP in percentage of the limit of the service tier (at the end of the reporting interval). 這包括用於儲存下列記憶體內部 OLTP 物件的記憶體:記憶體優化資料表、索引和資料表變數。This includes memory used for storage of the following In-Memory OLTP objects: memory-optimized tables, indexes, and table variables. 它也包含用來處理 ALTER TABLE 作業的記憶體。It also includes memory used for processing ALTER TABLE operations.

如果資料庫中未使用記憶體內部 OLTP,則傳回0。Returns 0 if In-Memory OLTP is not used in the database.
avg_login_rate_percentavg_login_rate_percent **decimal (5,2) **decimal (5,2) 僅供參考之用。Identified for informational purposes only. 不支援。Not supported. 我們無法保證未來的相容性。Future compatibility is not guaranteed.
avg_instance_cpu_percentavg_instance_cpu_percent **decimal (5,2) **decimal (5,2) 平均資料庫 CPU 使用量,以 SQL Database 進程的百分比表示。Average database CPU usage as a percentage of the SQL Database process.
avg_instance_memory_percentavg_instance_memory_percent **decimal (5,2) **decimal (5,2) 平均資料庫記憶體使用量(以 SQL Database 進程的百分比表示)。Average database memory usage as a percentage of the SQL Database process.
cpu_limitcpu_limit **decimal (5,2) **decimal (5,2) 此資料庫在此間隔期間的虛擬核心數目。Number of vCores for this database during this interval. 針對使用以 DTU 為基礎之模型的資料庫,這個資料行是 Null。For databases using the DTU-based model, this column is NULL.
allocated_storage_in_megabytesallocated_storage_in_megabytes floatfloat 格式化的檔案空間量(以 MB 為單位),可用於儲存資料庫資料。The amount of formatted file space in MB made available for storing database data. 格式化的檔案空間也稱為已配置的資料空間。Formatted file space is also referred to as data space allocated. 如需詳細資訊,請參閱: SQL Database 中的檔案空間管理For more information, see: File space management in SQL Database

提示

如需這些限制和服務層級的詳細內容,請參閱 服務層級For more context about these limits and service tiers, see the topics Service Tiers.

權限Permissions

此視圖適用于具有連接至虛擬 master 資料庫之許可權的所有使用者角色。This view is available to all user roles with permissions to connect to the virtual master database.

備註Remarks

Sys.resource_stats所傳回的資料會以您正在執行的服務層級/效能層級的最大允許限制百分比表示。The data returned by sys.resource_stats is expressed as a percentage of the maximum allowed limits for the service tier/performance level that you are running.

當資料庫是彈性集區的成員時,以百分比值呈現的資源統計資料會以彈性集區設定中設定之資料庫的最大限制百分比表示。When a database is a member of an elastic pool, resource statistics presented as percent values, are expressed as the percent of the max limit for the databases as set in the elastic pool configuration.

若要更細微地查看這項資料,請在使用者資料庫中使用 sys.dm_db_resource_stats 動態管理檢視。For a more granular view of this data, use sys.dm_db_resource_stats dynamic management view in a user database. 此檢視表每隔 15 秒就會擷取一次資料,並會維持 1 小時內的歷程記錄資料。This view captures data every 15 seconds and maintains historical data for 1 hour. 如需詳細資訊,請參閱 sys.dm_db_resource_stats (Azure SQL Database)For more information, see sys.dm_db_resource_stats (Azure SQL Database).

範例Examples

下列範例會傳回上一週平均至少為 80% 運算使用率的所有資料庫。The following example returns all databases that are averaging at least 80% of compute utilization over the last one week.

DECLARE @s datetime;  
DECLARE @e datetime;  
SET @s= DateAdd(d,-7,GetUTCDate());  
SET @e= GETUTCDATE();  
SELECT database_name, AVG(avg_cpu_percent) AS Average_Compute_Utilization   
FROM sys.resource_stats   
WHERE start_time BETWEEN @s AND @e  
GROUP BY database_name  
HAVING AVG(avg_cpu_percent) >= 80  

另請參閱See Also

服務層級 Service Tiers
服務層的功能和限制Service tier capabilities and limits