Slow GraphQL query getProjectMergeRequestsApprovalsEE causes high CPU duration and SLO violations
### Impact The `getProjectMergeRequestsApprovalsEE` GraphQL query is causing GraphQL Apdex SLO violations on GitLab Dedicated tenant `outer_tomato_gull`. **13.29% of these requests exceed the target duration of 5 seconds**, and **2.5% exceed 10 seconds**. This contributes to recurring `WebserviceServiceGraphqlQueryApdexSLOViolation` alerts multiple times per week, directly degrading user experience in the merge request approvals workflow. ### Summary The `getProjectMergeRequestsApprovalsEE` GraphQL operation exhibits excessive CPU duration when fetching merge request approval data. While DB and Gitaly times are acceptable, the CPU time dominates the request duration, suggesting inefficient application-level processing. Breakdown of requests over the week by duration bucket: ![image](/uploads/a5230220aa606589e8be0da6933a4bce/image.png){width=900 height=522} ### Problem When users query merge request approvals for a project (e.g., listing 50 open MRs with approval status), the query takes 20-30+ seconds to complete. The CPU time is disproportionately high. ### Example Log (sanitized) ```json { "path": "/api/graphql", "status": 200, "duration_s": 31.77, "target_duration_s": 5, "cpu_s": 21.72, "db_duration_s": 10.84, "gitaly_duration_s": 0.15, "redis_duration_s": 0.17, "queue_duration_s": 3.26, "graphql": { "operation_name": "getProjectMergeRequestsApprovalsEE", "complexity": 28, "depth": 6, "variables": { "fullPath": "<project_path>", "state": "opened", "firstPageSize": 50 }, "used_fields": [ "Project.mergeRequests", "MergeRequest.approved", "MergeRequest.approvalsRequired", "MergeRequest.approvalsLeft", "MergeRequest.approvedBy", "UserCoreConnection.nodes" ] }, "meta.feature_category": "code_review_workflow", "mem_bytes": 563962078, "mem_total_bytes": 1225005438 } ``` ### Observations - **CPU duration** (~21s) far exceeds DB + Gitaly + Redis combined (~11s) - **Memory allocation** is very high (563MB objects, 1.2GB total) - Feature category: `code_review_workflow` ### Related - Dedicated Incident: https://gitlab.com/gitlab-com/gl-infra/gitlab-dedicated/incident-management/-/issues/2992 - Related N+1 issue: https://gitlab.com/gitlab-org/gitlab/-/issues/592559 ### Environment - GitLab version: 18.8.6 - Deployment: GitLab Dedicated - tenant `outer_tomato_gull` - Query parameters: 50 open MRs with approval fields
issue