I found out that some queries are not optimal, for example:
select count(distinct RES.ID_) from ACT_RU_TASK RES inner join ACT_RU_VARIABLE A0 on RES.PROC_INST_ID_ = A0.PROC_INST_ID_ WHERE ( exists(select LINK.USER_ID_ from ACT_RU_IDENTITYLINK LINK where USER_ID_ = ? and LINK.TASK_ID_ = RES.ID_) or RES.ASSIGNEE_ = ? or RES.OWNER_ = ? ) and A0.TASK_ID_ is null and A0.NAME_= ? and A0.TYPE_ = ? and A0.TEXT_ = ?