compute_usage system table

更新时间:
复制 MD 格式

The compute_usage system table records per-table CU-Hours consumed by table optimization, aggregated by hour. Query it with Flink or another supported engine to analyze costs and optimize resource usage.

Note
  • compute_usage retains only the last 30 days of data. Partitions outside this window are automatically expired and cleaned up. To keep data longer, archive it periodically to a table you manage.

  • The CU-Hours in this table are intended for consumption analysis and trend monitoring. Refer to your bill for the final charges.

  • A table appears in compute_usage only when Storage optimization is enabled on it (enabled by default).

Field reference

Note

The following is the built-in schema definition. It is shown for reference only and does not need to be executed manually.

CREATE TABLE `compute_usage` (
  `database_name` STRING  COMMENT 'Database name',
  `table_id`      STRING  COMMENT 'Table ID',
  `table_name`    STRING  COMMENT 'Table name',
  `cu`            DOUBLE  COMMENT 'CU * Hours consumed',
  `start_time`    BIGINT  COMMENT 'Usage period start time (epoch milliseconds)',
  `end_time`      BIGINT  COMMENT 'Usage period end time (epoch milliseconds)',
  `dt`            STRING  COMMENT 'Date (yyyyMMdd)'
) COMMENT 'Hourly table-level compute resource consumption'
PARTITIONED BY (dt) WITH (
   'file.format' = 'avro',
   'partition.expiration-time' = '30 d',
   'partition.timestamp-formatter' = 'yyyyMMdd'
);

The fields are defined as follows:

Field

Description

database_name

The database name.

table_id

The table ID. For multi-table operations, database-level operations, and similar scenarios, the value is multi-table-job-default-table-id.

table_name

The table name. For multi-table operations, database-level operations, and similar scenarios, the value is multi-table-job-default-table-name.

cu

The CU-Hours consumed during the hour. This is the total across all lakehouse table optimization jobs, including intelligent compaction and lifecycle management.

start_time

The start time of the metering period, as an epoch millisecond timestamp. Typically aligned to the top of the hour.

end_time

The end time of the metering period, as an epoch millisecond timestamp. Typically aligned to the next top of the hour.

dt

The partition field. The date format is yyyyMMdd. Data is retained for the last 30 days.

Query examples

Use DLF or Flink SQL to query DLF system tables:

DLF data preview

You can run SQL queries directly using the DLF data preview and discovery features without setting up a separate compute engine. For details and pricing, see Data preview.

Flink SQL

To run the SQL examples using Flink, a DLF catalog must be configured in Flink. For detailed configuration steps, see Access DLF with Flink SQL.

Rank per-table compute consumption for a given day

SELECT
    database_name,
    table_name,
    table_id,
    SUM(cu) AS total_cu
FROM `<yourCatalogName>`.`system`.`compute_usage`
WHERE dt = '<date>'  -- Replace with the actual query date in yyyyMMdd format
GROUP BY database_name, table_name, table_id
ORDER BY total_cu DESC;

Track total compute consumption for a catalog

By day

SELECT
    dt,
    SUM(cu) AS daily_cu,
    min(start_time) AS min_start_time,
    max(start_time) AS max_start_time
FROM `<yourCatalogName>`.`system`.`compute_usage`
WHERE dt >= '<startDate>'  -- Replace with the actual start date
    AND dt <= '<endDate>'  -- Replace with the actual end date
GROUP BY dt
ORDER BY dt;

By hour

SELECT
    start_time,
    end_time,
    SUM(cu) AS hourly_cu
FROM `<yourCatalogName>`.`system`.`compute_usage`
WHERE dt = '<date>'  -- Replace with the actual query date
GROUP BY start_time, end_time
ORDER BY start_time;

Track compute consumption for a single table

By day

SELECT
    dt,
    SUM(cu) AS daily_cu,
    min(start_time) AS min_start_time,
    max(start_time) AS max_start_time
FROM `<yourCatalogName>`.`system`.`compute_usage`
WHERE table_id = '<yourTableId>'
    AND dt >= '<startDate>'  -- Replace with the actual start date
    AND dt <= '<endDate>'  -- Replace with the actual end date
GROUP BY dt
ORDER BY dt;

By hour

SELECT
    start_time,
    end_time,
    SUM(cu) AS hourly_cu
FROM `<yourCatalogName>`.`system`.`compute_usage`
WHERE table_id = '<yourTableId>'
    AND dt = '<date>'  -- Replace with the actual query date
GROUP BY start_time, end_time
ORDER BY start_time;