Skip to content

Missing index for queries run during upgrade #2710

Description

@mgallien

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions