Remove the `Gitlab::Database::Subquery.self_join` helper
What does this MR do?
This removal is possible now because:
- We do not support MySQL as a database anymore
- Our current version of Rails supports
.delete_all
withlimit
. This was not supported in Rails when we actually wrote this helper.
There was only one instance of usage of this helper (Gitlab::Database::Subquery.self_join
) in our repo and this helper seems to be written specifically to issue a delete_all
with limit
.
And since now this is supported by default in Rails, there is no need to use a self_join
and hence this helper can possibly be removed.
Going forward:
There are a couple of other instances of using self_join
mechanism that I noticed, but without the use of this helper. (Like here & here), but I will tackle these in a different MR and re-write them to a simple where().limit().delete_all
Database queries
Before:
DELETE
FROM "geo_repository_updated_events"
WHERE "geo_repository_updated_events"."id" IN
(SELECT "geo_repository_updated_events"."id"
FROM "geo_repository_updated_events"
INNER JOIN
(SELECT "geo_repository_updated_events".*
FROM "geo_repository_updated_events"
LIMIT $1) t2 ON "geo_repository_updated_events"."id" = t2."id");
After:
DELETE
FROM "geo_repository_updated_events"
WHERE "geo_repository_updated_events"."id" IN
(SELECT "geo_repository_updated_events"."id"
FROM "geo_repository_updated_events"
LIMIT $1);
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team