Help Center/ GaussDB/ API Reference/ APIs (Recommended)/ SQL Execution Plans/ Querying the Binding Status of a SQL Execution Plan
Updated on 2025-11-10 GMT+08:00

Querying the Binding Status of a SQL Execution Plan

Function

This API is used to query the binding status of a SQL execution plan. Before calling this API:

Constraints

This API is only available for nodes with CNs or DNs (primary or standby DNs) deployed.

Debugging

You can debug this API in API Explorer.

URI

POST /v3/{project_id}/instances/{instance_id}/sql/{node_id}/plans/query

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region.

To obtain the value, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 32 characters. Only letters and digits are allowed.

Default Value

N/A

instance_id

Yes

String

Definition

Instance ID, which uniquely identifies an instance.

Constraints

N/A

Range

The value can contain 36 characters. Only letters and digits are allowed.

Default Value

N/A

node_id

Yes

String

Definition

Node ID. Only CNs, primary DNs, or standby DNs of the non-log type are supported.

Constraints

N/A

Range

The value can contain 36 characters. Only letters and digits are allowed.

Default Value

N/A

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Definition

User token.

You can obtain the token by calling the IAM API used to obtain a user token.

The value of X-Subject-Token in the response header is the token value.

Constraints

N/A

Range

N/A

Default Value

N/A

X-Language

No

String

Definition

Language.

Constraints

N/A

Range

  • zh-cn
  • en-us

Default Value

en-us

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

sql_id

Yes

String

Definition

Normalized SQL ID. To obtain the value, see Querying Slow SQL Statements.

Constraints

N/A

page_size

Yes

String

Definition

Number of SQL execution plans displayed on each page.

Constraints

N/A

Range

An integer ranging from 1 to 100.

Default Value

N/A

offset

Yes

String

Definition

Start page number of SQL execution plans.

Constraints

N/A

Range

An integer greater than or equal to 0

Default Value

0

Response Parameters

Table 4 Response body parameters

Parameter

Type

Description

total

Integer

Definition

Total number of SQL execution plans.

Range

N/A

sql_plan_bind_state_list

Array of objects

Definition

Execution plans in the list. For details, see Table 5.

Table 5 sql_plan_bind_state_list

Parameter

Type

Description

outline

String

Definition

Outline of the current plan.

Range

N/A

cost

String

Definition

Cost of the SQL execution plan.

Range

N/A

status

String

Definition

Binding status.

Range

  • bind: The SQL execution plan is bound.
  • drop: The SQL execution plan is unbound.

sql_hash

String

Definition

Hash value of the SQL text.

Range

N/A

plan_id

String

Definition

SQL execution plan ID.

Range

N/A

Example Request

Querying the binding status of a SQL execution plan

POST https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/99220a1a5b714977b61be98185636732in14/sql/60856bc060f1476b81af52a17e0e5fc7no14/plans/query
{ 
  "offset" : 0, 
  "page_size" : 10, 
  "sql_id" : 418132115 
}

Example Response

Binding status of the SQL execution plan queried.

{ 
  "total" : 1, 
  "sql_plan_bind_state_list" : [ { 
    "outline" : "begin_outline_data\n use_hash_agg(@\"sel$1\")\n NestLoop(@\"sel$1\" root.store_sales@\"sel$1\" root.store_returns@\"sel$1\" root.store@\"sel$1\" root.customer@\"sel$1\" root.promotion@\"sel$1\" root.ad2@\"sel$1\" root.item@\"sel$1\")\n Leading(@\"sel$1\" ((((((root.store_sales@\"sel$1\" root.store_returns@\"sel$1\") root.store@\"sel$1\") root.customer@\"sel$1\") root.promotion@\"sel$1\") root.ad2@\"sel$1\") root.item@\"sel$1\"))\n NestLoop(@\"sel$1\" root.store_sales@\"sel$1\" root.store_returns@\"sel$1\" root.store@\"sel$1\" root.customer@\"sel$1\" root.promotion@\"sel$1\" root.ad2@\"sel$1\")\n Leading(@\"sel$1\" (((((root.store_sales@\"sel$1\" root.store_returns@\"sel$1\") root.store@\"sel$1\") root.customer@\"sel$1\") root.promotion@\"sel$1\") root.ad2@\"sel$1\"))\n NestLoop(@\"sel$1\" root.store_sales@\"sel$1\" root.store_returns@\"sel$1\" root.store@\"sel$1\" root.customer@\"sel$1\" root.promotion@\"sel$1\")\n Leading(@\"sel$1\" ((((root.store_sales@\"sel$1\" root.store_returns@\"sel$1\") root.store@\"sel$1\") root.customer@\"sel$1\") root.promotion@\"sel$1\"))\n NestLoop(@\"sel$1\" root.store_sales@\"sel$1\" root.store_returns@\"sel$1\" root.store@\"sel$1\" root.customer@\"sel$1\")\n Leading(@\"sel$1\" (((root.store_sales@\"sel$1\" root.store_returns@\"sel$1\") root.store@\"sel$1\") root.customer@\"sel$1\"))\n NestLoop(@\"sel$1\" root.store_sales@\"sel$1\" root.store_returns@\"sel$1\" root.store@\"sel$1\")\n Leading(@\"sel$1\" ((root.store_sales@\"sel$1\" root.store_returns@\"sel$1\") root.store@\"sel$1\"))\n HashJoin(@\"sel$1\" root.store_sales@\"sel$1\" root.store_returns@\"sel$1\")\n Leading(@\"sel$1\" (root.store_sales@\"sel$1\" root.store_returns@\"sel$1\"))\n TableScan(@\"sel$1\" root.store_sales@\"sel$1\")\n IndexOnlyScan(@\"sel$1\" root.store_returns@\"sel$1\" store_returns_pkey)\n IndexScan(@\"sel$1\" root.store@\"sel$1\" store_pkey)\n NestLoop_Index(@\"sel$1\" root.store@\"sel$1\", (root.store_sales@\"sel$1\"))\n IndexScan(@\"sel$1\" root.customer@\"sel$1\" customer_pkey)\n NestLoop_Index(@\"sel$1\" root.customer@\"sel$1\", (root.store_sales@\"sel$1\"))\n IndexOnlyScan(@\"sel$1\" root.promotion@\"sel$1\" promotion_pkey)\n NestLoop_Index(@\"sel$1\" root.promotion@\"sel$1\", (root.store_sales@\"sel$1\"))\n IndexScan(@\"sel$1\" root.ad2@\"sel$1\" customer_address_pkey)\n NestLoop_Index(@\"sel$1\" root.ad2@\"sel$1\", (root.customer@\"sel$1\"))\n IndexScan(@\"sel$1\" root.item@\"sel$1\" item_pkey)\n NestLoop_Index(@\"sel$1\" root.item@\"sel$1\", (root.store_sales@\"sel$1\"))\n version(\"1.0.0\")\n end_outline_data", 
    "cost" : "84178.87", 
    "status" : "bind", 
    "sql_hash" : "400834521", 
    "plan_id" : "378071839" 
  } ] 
}

Status Codes

Error Codes

For details, see Error Codes.