All Products
Search
Document Center

MaxCompute:COST SQL

Last Updated:Mar 26, 2026

Estimates the execution cost of a SQL job based on the amount of input data, the number of user-defined functions (UDFs), and query complexity.

Limitations

COST SQL does not support the following scenarios:

  • External tables: COST SQL cannot estimate the cost of SQL jobs that involve external tables.

  • UDF partition pruning: COST SQL cannot estimate the cost when partition pruning is enabled for UDFs, because the number of partitions to scan cannot be determined.

Usage notes

The estimation result is for reference only. Check your bill for actual costs.

Syntax

cost sql <sql_sentence>;

Parameters

ParameterDescription
sql_sentenceThe SQL statement to estimate execution cost for.

Example

The following example estimates the cost of a SELECT * query on the sale_detail table.

cost sql select * from sale_detail;

Output:

ID = 20150715113033121xxxxxxx
UDF:0
Complexity:1.0
Input:0 Bytes

The output fields are described in the following table.

FieldDescription
UDFThe number of UDFs used in the SQL job.
ComplexityThe complexity score of the SQL job. For more information, see SQL complexitySQL complexity.
InputThe amount of data scanned in the SQL job.