You can follow below recommendation proposed by Adobe.
4.3. Workflow purge
Each time a workflow is launched in AEM, a workflow instance is created. Once the workflow is
completed, the instance is archived. This applies to all workflows, including the DAM Update
Asset workflow. As the number of archived instances increases, the repository will become
bloated and queries that search through the workflow hierarchy will begin to suffer from performance
degradation.
In order to prevent repository growth and slow queries related to workflows, it is recommended
to run a workflow purge regularly. Workflow purge maintenance task is by default added to
weekly maintenance window. In order to be effective, purge configuration must be created in
OSGi configuration console
http://<HOST>:<PORT>/system/console/configMgr
In the page locate section “Adobe Granite Workflow Purge Configuration” and press ‘+’ button.
In popup dialog you can enter values for following properties:
• Job Name – descriptive name
• Workflow Status – denotes the status of the workflow that is considered to be deleted;
by default and in most cases, it should be COMPLETED
• Models To Purge – list of all workflow models for which their corresponding instances
should be deleted; if the list is empty, all modes are considered
• Workflow Age – how old workflows should be before they are purged
Thanks,
Kishore