共用方式為


預測優化系統數據表參考

重要

此系統數據表位於公開預覽版 。 若要存取資料表,必須在您的 system 目錄中啟用架構。 如需詳細資訊,請參閱 啟用系統資料表架構

注意

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

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

資料表路徑:此系統資料表位於 system.storage.predictive_optimization_operations_history

配送考量

  • 數據最多可能需要 24 小時才能填入。
  • 預測性優化可能會在相同的叢集上執行多個作業。 如果是,則將每個操作所分配的 DBU 份額進行近似計算。 這就是為什麼 usage_unit 設定為 ESTIMATED_DBU。 不過,在叢集上消耗的 DBU 總數將會是準確的。

預測優化數據表架構

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

欄位名稱 資料類型 描述 範例
account_id 字串 帳戶的 ID。 11e22ba4-87b9-4cc2-9770-d10b894b7118
workspace_id 字串 預測優化執行作業的工作區標識碼。 1234567890123456
start_time 時間戳記 作業開始的時間。 時區資訊會記錄在值結尾,+00:00 表示 UTC。 2023-01-09 10:00:00.000+00:00
end_time 時間戳記 作業結束的時間。 時區資訊會記錄在值結尾,+00:00 表示 UTC。 2023-01-09 11:00:00.000+00:00
metastore_name 字串 優化數據表所屬之中繼存放區的名稱。 metastore
metastore_id 字串 優化資料表所屬的中繼存放區識別碼。 5a31ba44-bbf4-4174-bf33-e1fa078e6765
catalog_name 字串 優化數據表所屬目錄的名稱。 catalog
schema_name 字串 優化數據表所屬的架構名稱。 schema
table_id 字串 已優化資料表的 ID。 138ebb4b-3757-41bb-9e18-52b38d3d2836
table_name 字串 優化數據表的名稱。 table1
operation_type 字串 已執行的優化作業。 值將會是COMPACTIONVACUUMANALYZECLUSTERING COMPACTION
operation_id 字串 優化作業的標識碼。 4dad1136-6a8f-418f-8234-6855cfaff18f
operation_status 字串 優化作業的狀態。 值會是 SUCCESSFULFAILED: INTERNAL_ERROR SUCCESSFUL
operation_metrics map[string, string] 已執行之特定優化的其他詳細數據。 請參閱 作業計量 {"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

作業計量

operation_metrics 資料列中記錄的計量會根據作業類型而有所不同:

  • COMPACTIONnumber_of_compacted_files、、 amount_of_data_compacted_bytesnumber_of_output_filesamount_of_output_data_bytes
  • VACUUMnumber_of_deleted_filesamount_of_data_deleted_bytes
  • ANALYZEamount_of_scanned_bytesnumber_of_scanned_filesstaleness_percentage_reduced
  • CLUSTERINGnumber_of_removed_files、、 number_of_clustered_filesamount_of_data_removed_bytesamount_of_clustered_data_bytes
  • AUTO_CLUSTERING_COLUMN_SELECTIONold_clustering_columnsnew_clustering_columnshas_column_selection_changedadditional_reason(包括數據列選取範圍有或未變更的原因)

查詢範例

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

本文包含下列範例查詢:

過去 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