This is one of the biggest offenders of write queries changing more than 1,000 rows (example). This can lead to read-only time and replication lag.
The query either should have a limit (and leave the rest to a job) or simply trigger a job for the clean up. I assume the former is easier as most users don't have a big reading list.
The limit value should come from the config $wgUpdateRowsPerQuery