-
- Downloads
There was an error fetching the commit references. Please try again later.
Preload routes information
This fixes a high frequency N+1 issue: `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 these queries: ```sql SELECT "routes".* FROM "routes" WHERE "routes"."source_id" = $1 AND "routes"."source_type" = $2 LIMIT $3 ``` This is unnecessary as we already join `routes` in `Routable#find_by_full_path` anyways.
Showing
- app/controllers/admin/groups_controller.rb 5 additions, 1 deletionapp/controllers/admin/groups_controller.rb
- app/models/concerns/routable.rb 2 additions, 2 deletionsapp/models/concerns/routable.rb
- changelogs/unreleased/ab-routable-nplus1.yml 5 additions, 0 deletionschangelogs/unreleased/ab-routable-nplus1.yml
- spec/models/concerns/routable_spec.rb 7 additions, 0 deletionsspec/models/concerns/routable_spec.rb
changelogs/unreleased/ab-routable-nplus1.yml
0 → 100644
Please register or sign in to comment