AnalyticDB for MySQL Edition allows you to asynchronously submit an import or export task.

Asynchronously submit a task

  • Syntax
    submit job INSERT overwrite INTO xxx SELECT ...FROM

    After you execute the preceding statement, a job ID is returned.

  • Example
    mysql> submit job INSERT overwrite INTO test SELECT * FROM test_external_table;
    +---------------------------------------+
    | job_id                               |
    +---------------------------------------+
    | 2017112122202917203100908203303000715 |
  • Priority-based scheduling

    AnalyticDB for MySQL V3.1.3.6 and later support priority-based scheduling. You can use a hint to specify the priority of an asynchronous task. The default priority value is 1. A larger value indicates a higher priority and will be prioritized by the system.

    mysql> /*+async_job_priority=10*/ submit job INSERT overwrite INTO test SELECT * FROM test_external_table;

Query the status of an asynchronous task

  • Syntax
    SHOW job STATUS WHERE job='job_id';
  • Example
    mysql> SHOW job STATUS WHERE job='2017112122202917203100908203303000715';
    +---------------------------------------+-------------+---------+----------+-----------------------+-----------------------+--------------------------------------+
    | job_id                              | schema_name | status  | fail_msg | create_time           | update_time           | definition                           |
    +---------------------------------------+-------------+---------+----------+-----------------------+-----------------------+--------------------------------------+
    | 2017112122202917203100908203303000715 | test    | RUNNING | NULL     | 2017-11-21 22:20:31.0 | 2017-11-21 22:20:40.0 |  insert into test select * from test |
  • Task status
    • INIT: indicates that the task is being initialized.
    • RUNNING: indicates that the task is running.
    • FINISH or FAILED: indicates that the task is successful or fails.

Terminate a task

  • Syntax
    CANCEL job 'job_id'
  • Example
    mysql> CANCEL job '2017112122202917203100908203303000715';
  • Note
    • Unscheduled, failed, and successful tasks are removed from the queue.
    • If a running task is terminated, imported data is rolled back.