All Products
Search
Document Center

MaxCompute:Cost estimation

Last Updated:Feb 19, 2025

Before you execute an SQL query, you can use the cost sql command to query the amount of computing resources that will be consumed. The cost sql command can be used to estimate the cost of executing an SQL job based on the amount of input data, number of user-defined functions (UDFs), and SQL complexity. This command helps reduce costs, improve efficiency, and properly plan resources. If partition pruning is enabled for the UDFs, you cannot estimate the expense in this case because the number of finally scanned partitions cannot be determined.

Note

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

Syntax

cost sql <sql_sentence>;

Parameters

sql_sentence: the SQL statement for which you want to estimate the execution cost.

Example

cost sql select * from sale_detail;

The following result is returned:

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

The following items describe the output parameters:

  • UDF: the number of UDFs that are used in an SQL job.

  • Complexity: the complexity of an SQL job. For more information, see SQL complexity.

  • Input: the amount of data scanned in an SQL job.