All Products
Search
Document Center

MaxCompute:Cost estimation

Last Updated:Mar 26, 2026

Before running an SQL query, use the cost sql command to estimate the computing resources it will consume. The estimate is based on three factors: the amount of input data, the number of user-defined functions (UDFs), and the SQL complexity. This helps you reduce costs, improve efficiency, and plan resources effectively.

Note

The result is for reference only. You can view your bill for the actual costs.

Limitations

If partition pruning is enabled for UDFs, cost sql cannot produce an estimate because the number of partitions to be scanned cannot be determined in advance.

Syntax

cost sql <sql_sentence>;

Parameters

Parameter Description
sql_sentence The SQL statement for which you want to estimate the execution cost.

Example

Run cost sql against a table to see its estimated resource consumption:

cost sql select * from sale_detail;

Output:

ID = 20150715113033121xxxxxxx
UDF:0
Complexity:1.0
Input:0 Bytes
Field Description
UDF The number of UDFs used in the SQL job.
Complexity The complexity of the SQL job. For more information, see SQL complexity.
Input The amount of data scanned in the SQL job.