Camunda db clean up sql queries

HI Team,

Can someone share database clean up queries for camunda. We need queries to
clear completed processes older than 30 days
clear failed jobs which are older than 30 days and failed jobs .

Atleast, please share the table names which we can use for the same.

Thanks,
Amol

HI @Amol23,

would a batch operation be an option for you?

Cheers,
Askar.

Hi Askar,

This is for version 7.6 however I am using 7.4.

Regards,
Amol

Hi @Amol23,

I would strongly recommend to update to version 7.6, as the batch version is the easiest and fastest version to clean up your database. If this is not an option here are some hints that might help:

  • the tables that are probably interesting for you, are the ACT_HI_* tables (have a look at the dabase schema for more information)).
  • I just assume you are using the rest api:
  • first you can query for all historic process instances that were finished previous to 30 days ago. Have a look here and there especially the finishedBefore field might interest you.
  • With the given process instance ids you can now delete them manually (see here).

The deletion of the historic process instance will cause the deletion of respective historic activities, historic tasks and historic details (variable updates, form properties) as well.

Best,
Johannes

1 Like

OK got with history table but I found lots of questions which are still unanswered how to get clean up of ACT_GE_BYTEARRAY. In my case its almost 120GB.

Hi @Amol23,

I’ve recently updated this snippet: https://github.com/camunda/camunda-consulting/tree/master/snippets/clean-up-history

Maybe this helps you to find the relevant relations.

Cheers, Ingo

Hi

https://github.com/camunda/camunda-consulting/tree/master/snippets/clean-up-history

Can we have an updated link ? Thx!

Hi @Olivier_Albertini,

as we introduced the history cleanup a while ago (https://docs.camunda.org/manual/7.12/user-guide/process-engine/history/#history-cleanup), we recommend this as the actual cleanup procedure.

Hope this helps, Ingo

        Date date =  Date.from(LocalDate.now().minusDays(30).atStartOfDay(ZoneId.systemDefault()).toInstant());
        List<Deployment> list = repositoryService.createDeploymentQuery().deploymentBefore(date).list();
        boolean cascade = true; // should delete till running process instance also ? true : false  
        for (Deployment deployment : list) {
            repositoryService.deleteDeployment(deployment.getId(), cascade);
        }
1 Like