Reduce headPipeline queries in the merge request dashboard

What does this MR do and why?

Fixes two performance problems with headPipeline in the merge request dashboard GraphQL query (requestingReviewAuthorOrAssignee), found in a production performance bar profile.

  • The headPipeline lookahead preloaded the merge_request_diff association. That association has an order scope, so the preload loaded every diff version of each merge request (131 ms for 8 merge requests). The field only needs the head SHA of the latest diff, so the preload now uses latest_merge_request_diff, like the detailed_merge_status preload already does.
  • headPipeline { detailedStatus } ran one p_ci_builds count query for each successful pipeline, because the status factory forced the number_of_warnings BatchLoader one pipeline at a time. PipelineType#detailed_status now queues the count for successful pipelines before the status is built, so 8 queries become 1.

References

Screenshots or screen recordings

Before After

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading