Project

General

Profile

Actions

Patch #39840

closed

Optimize `Issue#relations` method to fetch both `relations_from` and `relations_to` using a single query

Added by Go MAEDA about 1 year ago. Updated 12 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Performance
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

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

optimize-relation.patch (498 Bytes) optimize-relation.patch Go MAEDA, 2023-12-13 14:17
Actions #1

Updated by Go MAEDA about 1 year ago

  • Target version set to 6.0.0
Actions #2

Updated by Go MAEDA 12 months ago

  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch in r22572.

Actions

Also available in: Atom PDF