GraphQL boards lists query times out
Loading the Open list in https://gitlab.com/groups/gitlab-org/plan-stage/-/boards times out when graphql_board_lists
is enabled.
This is the SQL that is timing out from Sentry:
SELECT COUNT(*) AS count_all, "issues"."id" AS issues_id
FROM "issues"
INNER JOIN "projects" ON "projects"."id" = "issues"."project_id"
LEFT JOIN project_features ON projects.id = project_features.project_id WHERE (
issues.confidential IS NOT TRUE
OR (issues.confidential = $1
AND (issues.author_id = $2
OR EXISTS (SELECT $3 FROM issue_assignees WHERE user_id = $4 AND issue_id = issues.id)
OR EXISTS (SELECT $5 FROM "project_authorizations" WHERE "project_authorizations"."user_id" = $6 AND (project_authorizations.project_id = issues.project_id) AND (project_authorizations.access_level >= $7))))) AND "projects"."namespace_id" IN (WITH RECURSIVE "base_and_descendants" AS ((SELECT "namespaces".* FROM "namespaces" WHERE "namespaces"."type" = $8 AND "namespaces"."id" = $9)
UNION
(SELECT "namespaces".* FROM "namespaces", "base_and_descendants" WHERE "namespaces"."type" = $10 AND "namespaces"."parent_id" = "base_and_descendants"."id")) SELECT "namespaces"."id" FROM "base_and_descendants" AS "namespaces") AND (EXISTS (SELECT $11 FROM "project_authorizations" WHERE "project_authorizations"."user_id" = $12 AND (project_authorizations.project_id = projects.id) AND (project_authorizations.access_level >= $13)) OR projects.visibility_level IN ($14,$15)) AND ("project_features"."issues_access_level" IS NULL OR "project_features"."issues_access_level" IN ($16,$17) OR ("project_features"."issues_access_level" = $18 AND EXISTS (SELECT $19 FROM "project_authorizations" WHERE "project_authorizations"."user_id" = $20 AND (project_authorizations.project_id = projects.id) AND (project_authorizations.access_level >= $21)))) AND ("issues"."state_id" IN ($22)) AND "projects"."archived" = $23 AND "issues"."issue_type" IN ($24, $25) AND NOT (EXISTS (SELECT "label_links".* FROM "label_links" WHERE (label_links.target_type = $26) AND ("issues"."id" = "label_links"."target_id") AND "label_links"."label_id" = $27 LIMIT $28))
GROUP BY "issues"."id" LIMIT $29
/*application:web,controller:graphql,action:execute,correlation_id:01EX3X6QWM6X1943CJB82N9XFW*/
The GraphQL query that fails: https://gitlab.com/gitlab-org/plan/-/snippets/2065187
Edited by Heinrich Lee Yu