cancel
Showing results for 
Search instead for 
Did you mean: 

Best way to delete history

astrand
Champ in-the-making
Champ in-the-making
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?
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
You are loading ALL 100K objects in memory. That is not going to scale.
That is why paging was invented. The query api supports it.