Skip to main content

2 Create an Optimization

Description: Create an optimization task using an existing workspace ID (workspaceId) or DDL statements and SQL statements to be optimized, and return the optimization result status and corresponding optimization result ID (analysisId).

2.1. Interface URL

Post http://${server-host}:${server-port}/api/v1/createAnalysis  

2.2. Request Parameters

FieldTypeRequiredDescription
userKeyStringYActivation code
workspaceStringYCreated workspace ID or DDL text corresponding to the workspace
dbTypeStringNRequired when workspace is ddl, default mysql if not filled
workloadStringYSQL to be optimized
queryModeStringYType of SQL to be optimized plain_sql / mysql_query_log / postgresql_query_log
validateFlagbooleanNWhether to perform validate operation when executing analysis (only takes effect when the workspaceId corresponds to an online workspace), default false

Request Example

{  
"userKey": "CB698418-88B25371-67F15F01-XXXXXXXX",
"workspace": "CREATE TABLE `organization` (`org_id` bigint(20) NOT NULL)",
"dbType": "mysql",
"workload": "select * from organization where adm_id = 100 and adm_name = null;",
"queryMode": "plain_sql",
"validateFlag": false
}

2.3. Response

FieldTypeDescription
codeintStatus code
messageStringDescription
dataObjectData

Data structure of data

FieldTypeDescription
analysisIdStringOptimization ID
statusStringOptimization status

Response Example

  • Success
{  
"code": 200,
"message": "Success",
"data": {
"analysisId": "1730505660018876418",
"status": "success"
}
}
  • Failure
{  
"code": 400,
"message": "Analysis creation failed",
"data": null
}