During upgrade, some SQL DELETE requests may be run on the activity table that would miss an index to be run quickly.
The request have a WHERE clause lie this one:
WHERE affecteduser <> ...
AND object_type = 'calendar'
AND object_id = ...
AND subjectparams LIKE '%...%'
Creating a new index like this
ALTER TABLE nextcloud_db.oc_activity
ADD INDEX activity_object_cleanup_idx (object_type, object_id),
ALGORITHM=INPLACE,
LOCK=NONE;
This changed the execution plan from a full table scan to an index query.
Doing that solved the slow upgrade process.
During upgrade, some SQL DELETE requests may be run on the activity table that would miss an index to be run quickly.
The request have a WHERE clause lie this one:
Creating a new index like this
This changed the execution plan from a full table scan to an index query.
Doing that solved the slow upgrade process.