Actions
Patch #39840
closedOptimize `Issue#relations` method to fetch both `relations_from` and `relations_to` using a single query
Description
This patch updates `Issue#relations` method to efficiently fetch both `relations_from` and `relations_to` using a single ActiveRecord query. This optimization reduces database calls and improves performance.
Before:
IssueRelation Load (0.2ms) SELECT "issue_relations".* FROM "issue_relations" WHERE "issue_relations"."issue_from_id" = $1 [["issue_from_id", 1]] ↳ app/models/issue.rb:1169:in `relations' IssueRelation Load (0.5ms) SELECT "issue_relations".* FROM "issue_relations" WHERE "issue_relations"."issue_to_id" = $1 [["issue_to_id", 1]] ↳ app/models/issue.rb:1169:in `relations'
After:
IssueRelation Load (0.7ms) SELECT "issue_relations".* FROM "issue_relations" WHERE (issue_to_id = 1 OR issue_from_id = 1) ↳ app/models/issue.rb:1171:in `sort'
Files
Actions