AnsweredAssumed Answered

Best way to delete history

Question asked by astrand on Feb 16, 2015
Latest reply on Feb 18, 2015 by jbarrez
I created 100K process records in the H2 database and want to delete.  I saw a post to use the deleteHistoricProcessInstance() API.  So I wrote the following code

<blockcode>
HistoryService historyService = processEngine.getHistoryService();
HistoricActivityInstanceQuery haiq = historyService.createHistoricActivityInstanceQuery().activityId("testStartEvent");
List<HistoricActivityInstance> hain = haiq.list();
String processInstanceID;
for (int inx=0;inx<hain.size();inx++) {
   processInstanceID = hain.get(inx).getProcessInstanceId();
   historyService.deleteHistoricProcessInstance(processInstanceID);
}
</blockcode>

This has been running for about an hour.  Is there a better way to do this?  Should I just delete records with a date range or something?

Outcomes