SonarQube Migration 8.2 step #3208 "Remove old Security Review Rating measures" is slow because not using indexes to delete the metrics.
The solution is to split this migration into two parts, with distinct responsibility:
- one to delete the metrics from live_measures
- one to delete the metrics from project_measures
For live_measures, we rework the query to benefit from the existing composite index on component_uuid + metric_id
For project_measures, we are adding a dedicated technical index for this migration on metric_uuid, moving the purge step to 8.4 (metric_id is migrated to metric_uuid in SQ 8.4, so with an index on metric_uuid instead of metric_id, we can keep it for use later on)