Business Process list is slow
A lot of BP instances
Solution: Mark BP instances as deleted
Recommendation for execution:
- Script should be used single time
- If you want to do it again - change table name inside the script
- If you want to configure number of instances - change variable inside the script
Script:
Mark as deleted
set @remained_completed_instances_per_definition=100;
create table `Run_mark_deleted` as
SELECT z.campaign_number, z.campaign_id, step.rootRunUUID, z.id, step.uuid, step.status, step.businessProcessStatus
FROM (
SELECT @campaign_number := IF(@campaign_id = campaign_id, @campaign_number + 1, 1) AS campaign_number,
@campaign_id := campaign_id as campaign_id,
uuid, id
FROM
(SELECT @campaign_number := 1) x,
(SELECT id, uuid, @campaign_id := campaign_id as campaign_id
FROM Run
WHERE uuid = rootRunUUID AND campaignMap_id IS NOT NULL AND businessProcessStatus = 'COMPLETED'
ORDER BY campaign_id, id DESC) y
) z
join Run step on step.rootRunUUID = z.uuid;
update Run r
join `Run_mark_deleted` rmd on rmd.uuid = r.uuid
SET r.status = 'DELETED', r.businessProcessStatus = IF(r.businessProcessStatus IS NULL, NULL,'DELETED')
where rmd.campaign_number > @remained_completed_instances_per_definition;
Unmark as deleted
set @remained_completed_instances_per_definition=100;
update Run r
join Run_mark_deleted rmd on rmd.uuid = r.uuid
SET r.status = rmd.status, r.businessProcessStatus = rmd.businessProcessStatus
where rmd.campaign_number > @remained_completed_instances_per_definition;
Scheduled: Mark as deleted all campaign that has date more less one day
update Campaign c SET c.status = 'DELETED' WHERE c.creatioDate < DATE_SUB(NOW(), INTERVAL 1 DAY);
update Run r
join Campaign c on c.id = r.campaign_id
SET r.status = 'DELETED', r.businessProcessStatus = IF(r.businessProcessStatus IS NULL, NULL,'DELETED'), c.status = 'DELETED'
WHERE c.creatioDate < DATE_SUB(NOW(), INTERVAL 1 DAY);