All Products
Search
Document Center

MaxCompute:Consumption control

Last Updated:Jun 20, 2026

This topic describes how to control the consumption of pay-as-you-go computing tasks.

Features

MaxCompute pay-as-you-go resources are elastic and scale on demand, with no preset limits on resource usage. To avoid unexpected costs, monitor the consumption of your computing tasks. MaxCompute provides the following consumption control features:

Feature

Control method

Description

Per-statement resource limit

Limit resource consumption

MaxCompute estimates the resource consumption of an SQL statement before it runs. If the estimated consumption exceeds a preset threshold, the statement is blocked, and the system returns a failure status and an error message. This feature helps prevent a single SQL statement from incurring high costs.

Daily cumulative spend limit

Cost alert

Monitors the daily cumulative consumption of standard SQL in a project. If the sum of the day's accumulated consumption and the estimated consumption of a new SQL statement exceeds the preset threshold, the new statement is blocked. The system returns a failure status and an error message. This feature helps prevent daily standard SQL consumption from exceeding your budget.

Note

Daily cumulative SQL consumption refers only to metered usage that has not yet been billed. It does not include any discounts or promotions.

Per-statement resource limit

Configuration

You can set a per-statement resource limit in the following ways:

  • Project-level setting

    The project owner or a user with the Super_Administrator role must run the following command to enable or disable the per-statement resource limit.

    -- Enable the per-statement resource limit.
    SETPROJECT odps.sql.metering.value.max=<m_value>;
    -- Disable the per-statement resource limit.
    SETPROJECT odps.sql.metering.value.max;

    The m_value parameter is the maximum consumption threshold for a single SQL statement. It is calculated as SQL read volume (GB) × SQL complexity and is not a monetary amount.

    Note

    A project's per-statement consumption is constrained by m_value. If a statement's estimated consumption exceeds this m_value, the system blocks its execution.

  • Session-level setting

    To enable a per-statement resource limit for a single execution, submit the following command along with your SQL statement. If you do not include this command, the limit is disabled. This setting is valid only for the current execution.

    SET odps.sql.metering.value.max=<m_value>;

Recommendations

Follow these best practices:

  • Set a project-level m_value based on historical SQL consumption and your expected spending.

    • You can download daily detailed metering data and calculate the resource consumption for SQL tasks (tasks with a data classification of ComputationSql) at the project level. Resource consumption is calculated as SQL read volume (GB) × SQL complexity. Determine a suitable value based on the highest normal daily consumption, factoring in business fluctuations.

    • Alternatively, you can convert compute consumption to a cost . Based on your business needs, determine an acceptable cost, and then convert that cost back into a consumption value: .

  • Set a project-level limit first, then use a session-level m_value limit for specific, exceptional SQL statements.

    Note
    • Before setting a session-level limit, confirm that the specific SQL statement truly requires it to avoid misuse.

    • If both project-level and session-level limits are set, the session-level limit takes precedence.

      For example, if a project's m_value is set to 100, but a specific SQL statement within that project has a session-level m_value of 200, the statement is blocked only if its estimated consumption exceeds 200, not 100. Other SQL statements without a session-level limit still adhere to the project's limit of 100 and are blocked if their estimated consumption exceeds 100.

  • Setting either a project-level or session-level limit affects task execution. Use these limits with a task failure alert feature, such as DataWorks intelligent monitoring, to detect task failures promptly and intervene manually. This prevents critical tasks from being blocked and impacting business operations.

Daily cumulative spend limit

Configuration

You can set a daily cumulative spend limit for a project using the following command. Only the project owner or a user with the Super_Administrator role can run this command.

SETPROJECT odps.costcontrol.rule={"byDate":{"sql":<Limit>}};
  • byDate: Sets a daily limit. The cumulative consumption is calculated for the period from 00:00:00 to 23:59:59 (UTC+8). The counter resets on the next day.

  • Limit: The daily cumulative spending threshold for standard SQL in the project, specified in USD. This consumption tracking does not include any discounts or promotions.

    Note

    Cost per SQL statement = Scanned data volume (GB) × Complexity × 0.0438. In the Saudi Arabia (Riyadh) region, which is operated by a partner, the standard SQL billing rate is 0.05256 USD/GB.

Usage notes

After setting the limit using this command, be aware of the following rules:

Rule type

System behavior

Example and recommendation

First-time setup

The system accumulates the total daily consumption of standard SQL in the project and estimates the consumption of newly submitted standard SQL statements.

Example: When you first set the project-level limit by running SETPROJECT odps.costcontrol.rule={"byDate":{"sql":100}};, the system starts accumulating the daily total and estimating the cost of new tasks.

Updating an existing value

The system compares the new consumption estimate against the accumulated value and the new limit to determine whether to block the task.

Suppose the original daily limit was 100 and the current accumulated consumption is 99. You change the limit to 150 and then submit a new standard SQL statement.

The system first estimates the cost of the new SQL statement (for example, 20). If the sum of the estimated cost and the accumulated consumption (20 + 99) is less than or equal to 150, the SQL statement runs. Otherwise, it is blocked.

Sum of daily accumulated and estimated consumption exceeds the Limit

The system blocks the newly submitted standard SQL task from executing and returns an error message.

  • Error example:

    After you set a consumption limit using the setproject odps.costcontrol.rule={"byDate":{"sql":100}}; command, if the daily cumulative consumption of standard SQL in the project exceeds the limit, the task fails with the following error:

    Exceed Cost Limit : 
    {"AlreadyCost":"100.1","InstanceId":"xxx","Limit":"100","Project":"xxx","TaskType":"SQL","ThisTaskWillCost":"0","TimeWindow":"BYDATE"}
  • Recommendation:

    Use this feature with a task failure alert function, such as DataWorks intelligent monitoring, to be promptly notified of task failures. This allows you to intervene manually and prevent critical tasks from being blocked and impacting your business.