SQL, Spark, and MapReduce jobs submitted in the MaxCompute console are converted into MaxCompute instances. This topic describes common operations that can be performed on instances, such as querying the information and status of a specified instance, stopping an instance, and obtaining the operational logs of an instance.

Each MaxCompute instance has a unique ID. The instance ID is permanently valid. The following table describes common statements that are used for instance operations.
Operation Description Role Platform
View instance information Views instance information. Users who have read permissions on instances or the LIST permission on the objects in a project You can execute the statements that are described in this topic on the following platforms:
Query the instance status Queries the status of a specified instance. Users who have read permissions on instances
View information about the running instances Views the information about instances that are running in a project. Users who have read permissions on instances or the LIST permission on the objects in a project
Stop an instance Stops a specified instance that is in the Running state. Users who have write permissions on instances
Obtain job information about an instance Obtains job information based on a specified instance ID. Users who have read permissions on instances
Obtain the operational log of jobs in an instance Obtains the operational log of jobs based on a specified instance ID.

View instance information

Views instance information. The information includes StartTime (in seconds), RunTime (in seconds), Status, InstanceID, Owner, and Query statements.

  • Syntax
    show p|proc|processlist|instances [from <startdate>] [to <enddate>] [-p <project_name>] [-limit <number> | <number>] [-all];
    ls|list instances [from <startdate>] [to <enddate>] [-p <project_name>] [-limit <number> | <number>] [-all];

    The following statements are equivalent: show p, show proc, show processlist, show instances, ls instances, and list instances.

  • Parameters
    • startdate and enddate: optional. The instance information that is submitted by a user within the period from startdate to enddate is returned. The date specified by the startdate parameter must be earlier than the date specified by the enddate parameter. The instance information that is submitted on the day that is specified by enddate is not included. The values of the two parameters must be in the yyyy-mm-dd format and are accurate to the day. If you do not configure the parameters, the instance information that is submitted on the current day is returned.
    • project_name: optional. The name of the MaxCompute project to which the instance that you want to query belongs. You must have the permissions to view the instance of the MaxCompute project. If you do not configure this parameter, the instance of the current MaxCompute project is queried.
    • number: optional. The number of instances that you want to return.
    • If you configure this parameter, information about N instances that is submitted at the time nearest to the current time is returned in chronological order. N is specified by the number parameter. If you do not configure this parameter, information about the instances that meet specific requirements is returned. -limit <number> and number are equivalent.
    • -all: optional. Information about all instances that are run by the members of the MaxCompute project is returned. If you do not configure this parameter, information about the instances that are run by the current user in the MaxCompute project is returned.

      If the number parameter is not specified, information about up to 50 instances is returned by default. If the number parameter is configured, information about N instances is returned. N is specified by the number parameter.

  • Examples
    • Example 1: View the information about all instances that are run by the current user in the current MaxCompute project on the current day. Sample statement:
      show p;
      The following result is returned:
      StartTime             RunTime  Status   InstanceID                    Owner                            Query
      2021-09-14 11:43:04   0s       Success  20210914**************3rw2    ALIYUN$****@test.aliyunid.com
      2021-09-14 11:43:05   1s       Success  20210914**************5t32    ALIYUN$****@test.aliyunid.com select date_sub(datetime '2005-03-01 00:00:00', 1);
      2021-09-14 11:58:13   0s       Success  20210914**************5pr2    ALIYUN$****@test.aliyunid.com
      2021-09-14 11:58:15   1s       Success  20210914**************5qgr    ALIYUN$****@test.aliyunid.com select date_sub(date '2005-02-28', -1);
      2021-09-14 12:02:15   1s       Success  20210914**************h8o7    ALIYUN$****@test.aliyunid.com select date_sub('2008-03-01 00:00:00', 2);
      2021-09-14 12:02:15   0s       Success  20210914**************5t32    ALIYUN$****@test.aliyunid.com
      2021-09-14 12:02:31   0s       Success  20210914**************5pr2    ALIYUN$****@test.aliyunid.com
      2021-09-14 12:02:32   0s       Success  20210914**************euq2    ALIYUN$****@test.aliyunid.com select date_sub('2005-03-01 00:00:00', 2);
      2021-09-14 13:35:42   0s       Success  20210914**************1ms2    ALIYUN$****@test.aliyunid.com
      2021-09-14 13:35:43   0s       Success  20210914**************j8o7    ALIYUN$****@test.aliyunid.com select date_sub(getdate(),1);
      2021-09-14 13:40:40   1s       Success  20210914**************h3wz    ALIYUN$****@test.aliyunid.com select date_sub(getdate(),0);
      2021-09-14 13:40:40   0s       Success  20210914**************9nm7    ALIYUN$****@test.aliyunid.com
      12 instances
    • Example 2: View the information about the instances that are run by the current user in the current MaxCompute project within a specified period of time, and specify the number of instances whose information you want to query. Sample statement:
      show instances from 2021-09-14 to 2021-09-15 -limit 10;
      The following result is returned:
      StartTime             RunTime  Status   InstanceID                    Owner                            Query
      2021-09-14 11:58:13   0s       Success  20210914**************5pr2    ALIYUN$****@test.aliyunid.com
      2021-09-14 11:58:15   1s       Success  20210914**************5qgr    ALIYUN$****@test.aliyunid.com    select date_sub(date '2005-02-28', -1);
      2021-09-14 12:02:15   1s       Success  20210914**************h8o7    ALIYUN$****@test.aliyunid.com    select date_sub('2008-03-01 00:00:00', 2);
      2021-09-14 12:02:15   0s       Success  20210914**************5t32    ALIYUN$****@test.aliyunid.com
      2021-09-14 12:02:31   0s       Success  20210914**************5pr2    ALIYUN$****@test.aliyunid.com
      2021-09-14 12:02:32   0s       Success  20210914**************euq2    ALIYUN$****@test.aliyunid.com    select date_sub('2005-03-01 00:00:00', 2);
      2021-09-14 13:35:42   0s       Success  20210914**************1ms2    ALIYUN$****@test.aliyunid.com
      2021-09-14 13:35:43   0s       Success  20210914**************j8o7    ALIYUN$****@test.aliyunid.com    select date_sub(getdate(),1);
      2021-09-14 13:40:40   1s       Success  20210914**************h3wz    ALIYUN$****@test.aliyunid.com    select date_sub(getdate(),0);
      2021-09-14 13:40:40   0s       Success  20210914**************9nm7    ALIYUN$****@test.aliyunid.com
      10 instances
    • Example 3: View the information about the instances that are run by all users in another MaxCompute project within a specified period of time and specify the number of instances whose information you want to query. Sample statement:
      ls instances from 2021-09-14 to 2021-09-15 -p doc_test_dev -all -limit 10;
      The following result is returned:
      StartTime             RunTime  Status   InstanceID                    Owner                            Query
      2021-09-14 11:59:16   0s       Success  20210914**************6pr3    ALIYUN$****@test.aliyunid.com
      2021-09-14 11:59:20   1s       Success  20210914**************6qgr    ALIYUN$****@test.aliyunid.com    select date_sub(date '2007-02-26', -1);
      2021-09-14 12:02:19   1s       Success  20210914**************h8o7    ALIYUN$****@test.aliyunid.com    select date_sub('2009-03-01 00:00:00', 2);
      2021-09-14 12:02:25   0s       Success  20210914**************7t42    ALIYUN$****@test.aliyunid.com
      2021-09-14 12:02:37   0s       Success  20210914**************7pr2    ALIYUN$****@test.aliyunid.com
      2021-09-14 12:02:40   0s       Success  20210914**************emq2    ALIYUN$****@test.aliyunid.com    select date_sub('2015-03-01 00:00:00', 2);
      2021-09-14 13:35:42   0s       Success  20210914**************1ms2    ALIYUN$****@test.aliyunid.com
      2021-09-14 13:35:43   0s       Success  20210914**************68o7    ALIYUN$kiki                      select date_sub(getdate(),1);
      2021-09-14 13:45:40   1s       Success  20210914**************73wz    ALIYUN$kiki                      select date_sub(getdate(),0);
      2021-09-14 13:45:45   0s       Success  20210914**************9nm7    ALIYUN$dreak
      10 instances
    • Example 4: View the information about the instances that are run by all users in another MaxCompute project on the current day, and specify the number of instances whose information you want to query. Sample statement:
      show p -p doc_test_dev -all 5;
      The following result is returned:
      StartTime             RunTime  Status   InstanceID                    Owner                            Query
      2021-09-14 12:02:40   0s       Success  20210914**************emq2    ALIYUN$****@test.aliyunid.com    select date_sub('2015-03-01 00:00:00', 2);
      2021-09-14 13:35:42   0s       Success  20210914**************1ms2    ALIYUN$****@test.aliyunid.com
      2021-09-14 13:35:43   0s       Success  20210914**************68o7    ALIYUN$kiki                      select date_sub(getdate(),1);
      2021-09-14 13:45:40   1s       Success  20210914**************73wz    ALIYUN$kiki                      select date_sub(getdate(),0);
      2021-09-14 13:45:45   0s       Success  20210914**************9nm7    ALIYUN$dreak
      5 instances

Query the instance status

Queries the status of a specified instance. If the instance is created by a different user, an error is returned when you query the status of this instance.

  • Syntax
    status <instance_id>;
  • Parameter

    instance_id: required. The ID of an instance whose status you want to query. Each instance ID is unique.

  • Output
    An instance can be in one of the following states:
    • Running: The instance is running.
    • Success: The instance operation succeeds.
    • Waiting: The instance is waiting to run.
    • Failed: The job fails, but the data in the destination table is not modified.
    • Cancelled: The instance is stopped.
    • Terminated: The job is completed.
  • Example
    -- Query the status of the instance whose ID is 20131225123xxxxxxxxxxxxxxx. 
    status 20131225123xxxxxxxxxxxxxxx;
    The following result is returned:
    Success

View information about the running instances

Views the information about the instances that are running in a project. The information includes InstanceID, Owner, Type, StartTime, Progress, Status, Priority, RuntimeUsage (CPU/MEM), totalUsage (CPU/MEM), and QueueingInfo (POS/LEN).

  • Syntax
    -- View the information about the running instances that are submitted by the current account in the current project. 
    top instance;
    -- Return the information about all or a specified number of running instances in the current project. 
    top instance [-all][-limit <number>];
  • Parameters
    • -all: optional. Information about all jobs that are running in the current project is returned. By default, information about up to 50 jobs can be returned.
    • -limit number: optional. Information about a specified number of jobs that are running in the current project is returned.
  • Example
    -- Return the information about the first five instances that are running in the current project. 
    top instance -limit 5;
    The following result is returned:
    QueueingInstances: 0 total.

Stop an instance

Stops a specified instance that is in the Running state.
Note The execution of this statement is an asynchronous process. After the system accepts the request and returns a result, it does not mean that the distributed job has been stopped. Instead, it only means that the system has received the request. You must execute the STATUS statement to check the status of the instance.
  • Syntax
    kill <instance_id>;
  • Parameter

    instance_id: the ID of an instance. Each instance ID is unique. Only an instance in the Running state can be specified. Otherwise, an error is returned.

  • Example
    -- Stop the instance whose ID is 20131225123xxxxxxxxxxxxxxx. 
    kill 20131225123xxxxxxxxxxxxxxx;

Obtain job information about an instance

Obtains job information based on a specified instance ID. The information includes SQL, Owner, StartTime, EndTime, and Status.

  • Syntax
    desc instance <instance_id>;
  • Parameter

    instance_id: the ID of an instance. Each instance ID is unique.

  • Example
    -- Query job information about the instance whose ID is 20150715xxxxxxxxxxxxxxx. 
    desc instance 20150715xxxxxxxxxxxxxxx;
    The following result is returned:
    ID                                      20150715xxxxxxxxxxxxxxx
    Owner                                   ALIYUN$XXXXXX@alibaba-inc.com
    StartTime                               2015-07-15 18:34:41
    EndTime                                 2015-07-15 18:34:42
    Status                                  Terminated
    console_select_query_task_1436956481295 Success
    Query                                   select * from mj_test;

Obtain the operational log of jobs in an instance

Obtains the operational log of jobs based on a specified instance ID. The log includes the URL of Logview. You can view the log details of jobs in Logview.
Note You can open the Logview only for the instances that are created in the last three days. For instances that are created for more than three days, you can obtain the Logview URLs from their logs.
  • Syntax
    wait <instance_id>;
  • Parameter

    instance_id: the ID of an instance. Each instance ID is unique.

  • Example
    -- Query the operational log of jobs for the instance whose ID is 20170925161122379gxxxxxx. 
    wait 20170925161122379gxxxxxx;
    The following result is returned:
    ID = 20170925161122379g3xxxxxx
    Log view:
    http://logview.odps.aliyun.com/logview/?h=http://service.odps.aliyun.com/api&p=alian&i=201709251611223xxxxxxdqp&token=XXXXXXvbiI6IjEifQ==
    Job Queueing...
    Summary:
    resource cost: cpu 0.05 Core * Min, memory 0.05 GB * Min
    inputs:
            alian.bank_data: 41187 (588232 bytes)
    outputs:
            alian.result_table: 8 (640 bytes)
    Job run time: 2.000
    Job run mode: service job
    Job run engine: execution engine
    M1:
            instance count: 1
            run time: 1.000
            instance time:
                    min: 1.000, max: 1.000, avg: 1.000
            input records:
                    TableScan_REL5213301: 41187  (min: 41187, max: 41187, avg: 41187
    )
            output records:
                    StreamLineWrite_REL5213305: 8  (min: 8, max: 8, avg: 8)
    R2_1:
            instance count: 1
            run time: 2.000
            instance time:
                    min: 2.000, max: 2.000, avg: 2.000
            input records:
                    StreamLineRead_REL5213306: 8  (min: 8, max: 8, avg: 8)
            output records:
                    TableSink_REL5213309: 8  (min: 8, max: 8, avg: 8)