Skip to content

Add Gitlab::Database::Subquery.self_join to delete_all with limit

Toon Claes requested to merge tc-geo-prune-events-correctly-ce into master

What does this MR do?

delete_all doesn't support limit, so you'd need to subquery that. And instead of subquerying with where(id: query), it's better to use an INNER JOIN. This method also works with MySQL, while subquerying doesn't (without another layer of subquerying)

Reference: https://stackoverflow.com/questions/17892762/mysql-this-version-of-mysql-doesnt-yet-support-limit-in-all-any-some-subqu/17892886#17892886

This is a backport of https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/6175

Edited by Toon Claes

Merge request reports