Previous Next JavaScript must be enabled to correctly display this content

## 20.19 About Task Retention and Task Purging

Learn about task retention, task purging, and the Archive of Purged Task Files report.

APEX can create tasks with complex payloads. This means task data can grow exponentially, causing space and performance overloads. Periodically purging task data prevents overloading the system.

Task Retention Logic

A `DBMS_SCHEDULER` job runs on a daily basis to check all records in the task instance table. When `DBMS_SCHEDULER` runs, it:

- Keeps active, unassigned, and assigned tasks
- Purges completed tasks with a retention period that is less than or equal to the current date
- Purges all terminated, canceled, and errored tasks

  Note:

  Terminated and canceled tasks do not have a retention period, and only remain in the system until the daily `DBMS_SCHEDULER` job runs. This means terminated or canceled tasks exist in the task instance table for less than twenty-four hours.

The Archive of Purged Tasks Report saves a `JSON` document of tasks that are eligible for purge. After the report is generated, the tasks eligible for purge are cleaned up.

Task Retention Settings

The task retention policy determines how long to keep completed tasks. The default task retention period is seven days and the maximum task retention period is thirty days. An instance administrator can configure the task retention period in Instance Settings. For more information, see Configuring Workflow Settings in Oracle APEX Administration Guide.

Archive of Purged Task Files Report

The report of tasks that have been purged by the Task Purge job is located in Workspace Administration. For more information, see Accessing the Monitor Activity Page in Administration Services in Oracle APEX Administration Guide.

Files in the Purged Task Files report area are cleaned up every 30 days.

- Retrieving Tasks Before Purge
  Example code for retrieving tasks before purge.

Parent topic: Managing Workflows and Tasks

### 20.19.1 Retrieving Tasks Before Purge

Example code for retrieving tasks before purge.

This example uses an API to fetch purgeable tasks, retrieve the data, and handle those tasks in their own schema.

    merge
        into user_task_table    u
    using apex_purgeable_tasks  t
        on (u.task_id = t.task_id)
    when not matched then insert
        (u.task_id, u.task_type, u.subject, u.priority)
    values(t.task_id, t.task_type, t.subject, t.priority);

Parent topic: About Task Retention and Task Purging