Share via


預測優化系統數據表參考

重要

這項功能處於公開預覽狀態

注意

若要能夠存取此資料表,您必須啟用 storage 架構(請參閱 啟用系統數據表架構),而您的區域必須支援預測優化(請參閱 Azure Databricks 區域)。

本文概述預測優化作業記錄數據表架構,並提供範例查詢。 預測優化可將數據配置優化,以達到尖峰效能和成本效益。 系統數據表會追蹤這項功能的作業歷程記錄。 如需預測優化的資訊,請參閱 Delta Lake 的預測優化。

這個系統資料表位於 system.storage.predictive_optimization_operations_history

傳遞考慮

  • 數據最多可能需要 24 小時才能填入。
  • 預測性優化可能會在相同的叢集上執行多個作業。 如果是,則表示每個作業的 DBU 共用是近似的。 這就是為什麼 設定為ESTIMATED_DBUusage_unit 不過,在叢集上花費的 DBU 總數將會正確。

預測優化數據表架構

預測優化作業歷程記錄系統數據表會使用下列架構:

資料行名稱 資料類型 描述 範例
account_id 字串 帳戶的標識碼。 11e22ba4-87b9-4cc2-9770-d10b894b7118
workspace_id 字串 預測優化執行作業的工作區標識碼。 1234567890123456
start_time timestamp 作業開始的時間。 2023-01-09 10:00:00.000
end_time timestamp 作業結束的時間。 2023-01-09 11:00:00.000
metastore_name 字串 優化數據表所屬之中繼存放區的名稱。 metastore
catalog_name 字串 優化數據表所屬目錄的名稱。 catalog
schema_name 字串 優化數據表所屬的架構名稱。 schema
table_id 字串 優化數據表的標識碼。 138ebb4b-3757-41bb-9e18-52b38d3d2836
table_name 字串 優化數據表的名稱。 table1
operation_type 字串 已執行的優化作業。 值會是 COMPACTIONVACUUM COMPACTION
operation_id 字串 優化作業的標識碼。 4dad1136-6a8f-418f-8234-6855cfaff18f
operation_status 字串 優化作業的狀態。 值會是 SUCCESSFULFAILED: INTERNAL_ERROR SUCCESSFUL
operation_metrics map[string, string] 已執行之特定優化的其他詳細數據。 對於 COMPACTION 作業:(number_of_compacted_files、amount_of_data_compacted_bytes、number_of_output_files、amount_of_output_data_bytes)適用於 VACUUM 作業:(number_of_deleted_files、amount_of_data_deleted_bytes) {"number_of_output_files":"100","number_of_compacted_files":"1000","amount_of_output_data_bytes":"4000","amount_of_data_compacted_bytes":"10000"}
usage_unit 字串 此作業所產生的使用單位。 只能是一個值: ESTIMATED_DBU ESTIMATED_DBU
usage_quantity decimal 此作業所使用的使用量單位數量。 2.12

範例查詢

下列各節包含可用來深入瞭解預測優化系統數據表的範例查詢。 若要讓這些查詢能夠運作,您必須將大括弧 {{}} 內的值取代為您自己的參數。

本文包含下列範例查詢:

過去 30 天內有多少 DBU 使用預測優化?

SELECT SUM(usage_quantity)
FROM system.storage.predictive_optimization_operations_history
WHERE
     usage_unit = "ESTIMATED_DBU"
     AND  timestampdiff(day, start_time, Now()) < 30

預測優化在過去30天內花費最多的數據表為何?

SELECT
     metastore_name,
     catalog_name,
     schema_name,
     table_name,
     SUM(usage_quantity) as totalDbus
FROM system.storage.predictive_optimization_operations_history
WHERE
    usage_unit = "ESTIMATED_DBU"
    AND timestampdiff(day, start_time, Now()) < 30
GROUP BY ALL
ORDER BY totalDbus DESC

哪些數據表是執行最多作業的預測優化?

SELECT
     metastore_name,
     catalog_name,
     schema_name,
     table_name,
     operation_type,
     COUNT(DISTINCT operation_id) as operations
FROM system.storage.predictive_optimization_operations_history
GROUP BY ALL
ORDER BY operations DESC

針對指定的目錄,已壓縮多少個字節總數?

SELECT
     schema_name,
     table_name,
     SUM(operation_metrics["amount_of_data_compacted_bytes"]) as bytesCompacted
FROM system.storage.predictive_optimization_operations_history
WHERE
    metastore_name = {{metastore_name}}
    AND catalog_name = {{catalog_name}}
    AND operation_type = "COMPACTION"
GROUP BY ALL
ORDER BY bytesCompacted DESC

哪些數據表已清空最多位元組?

SELECT
     metastore_name,
     catalog_name,
     schema_name,
     table_name,
     SUM(operation_metrics["amount_of_data_deleted_bytes"]) as bytesVacuumed
FROM system.storage.predictive_optimization_operations_history
WHERE operation_type = "VACUUM"
GROUP BY ALL
ORDER BY bytesVacuumed DESC

預測優化所執行的作業成功率為何?

WITH operation_counts AS (
     SELECT
           COUNT(DISTINCT (CASE WHEN operation_status = "SUCCESSFUL" THEN operation_id END)) as successes,
           COUNT(DISTINCT operation_id) as total_operations
    FROM system.storage.predictive_optimization_operations_history
 )
SELECT successes / total_operations as success_rate
FROM operation_counts