Skip to content

Backend: Fix N+1 in previousStageJobsAndNeeds

Summary

An N+1 was discovered in previousStageJobsAndNeeds when the spec was updated for it by just adding one extra build that is part of an additional stage, which can be seen in this job: https://gitlab.com/gitlab-org/gitlab/-/jobs/4868684404.

Proposal

Since this would happen with the addition of the new previousStageJobs field in #389195 (closed) and the N+1s are compounded if we have both fields in the query, the N+1 should be fixed before #389195 (closed) is implemented.

Additional details

Some relevant technical details, if applicable, such as:

  • Does this need a feature flag?
  • Does there need to be an associated instrumentation issue created related to this work?
  • Is there an example response showing the data structure that should be returned (new endpoints only)?
  • What permissions should be used?
  • Is this EE or CE?
    • EE
    • CE
  • Additional comments:

Implementation Table

Group Issue Link
backend Backend: Fix N+1 in previousStageJobs (#424255 - closed)
backend Backend/Frontend: Add new `previousStagesJobs` ... (#389195 - closed)
backend 👈 You are here
backend Backend: Remove GraphQL field - previousStageJo... (#424417)

Links/References

Edited by Mark Nuzzo