In, you can submit data import and export tasks in asynchronous mode.

Submit a task asynchronously

  • Syntax
    
           submit job insert overwrite into xxx select ... 
         

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

  • Examples
    
           mysql> submit job insert overwrite into test select * from test_external_table; +---------------------------------------+ | job_id | +---------------------------------------+ | 2017112122202917203100908203303000715 | 
         
  • Priority-based scheduling

    Version 3.1.3.6 and later support priority-based scheduling. You can use the hint syntax to identify the priority of asynchronous tasks. The default priority value is 1. A greater value indicates a higher priority and that tasks are preferentially scheduled 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' 
         
  • Examples
    
           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 | 
         
  • Job Status Explained
    • INIT : a task enters a queue.
    • RUNNING : Starts to execute a task in the background.
    • FINISH / FAILED : indicates whether the task succeeds or fails.

Terminate a task

  • Syntax
    
           cancel job 'job_id' 
         
  • Examples
    
           mysql> cancel job '2017112122202917203100908203303000715'; 
         
  • Description
    • Unscheduled, failed, and successful tasks are removed from the queue.
    • Running tasks are terminated. Imported data is rolled back.