Preload routes information in Routable
What does this MR do?
Context: https://gitlab.com/gitlab-org/gitlab-ce/issues/64590
We observe a high frequency for this query:
SELECT "routes".\* FROM "routes"
WHERE "routes"."source_id" = ?
AND "routes"."source_type" = ?
LIMIT ?
This MR fixes a N+1 problem in Routable
:
RoutableActions#find_routable!
is used across many controllers to
retrieve e.g. the Project or Namespace by path. The #find_routable!
method calls #ensure_canonical_path
which in turn retrieves #full_path
from the given Routable.
This in turn triggers a lookup on routes
, leading to a high frequency
of the above query.
This is unnecessary as we already join routes
in
Routable#find_by_full_path
anyways.
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry for user-facing changes, or community contribution. Check the link for other scenarios.
Edited by Stan Hu