N+1 Query in namespaces api
The Namespaces API has a N+1 query problem as discussed here !22121 (comment 264034946)
TESTING
The test code is in the MR
THE N+1 queries
The N+1 queries in the namespace API stem from the 3 fields exposed using the Grape API builder. It seems very easy to make N+1 mistakes, due to the way fields are exposed in Grape. More APIs might risk having N+1 query problems. The fix for all 3 will require some thinking, if at all practical. The MR currently includes just the failed N+1 spec.
-
billable_members_count
=namespace.billable_members_count(options[:requested_hosted_plan])
-
full_path
orweb_url
in theRoutable
concern -
members_count_with_descendants
=namespace.users_with_descendants.count
Edited by 🤖 GitLab Bot 🤖