Project

General

Profile

Actions

Patch #24587

closed

Improve custom fields list performance

Added by Thomas Löber almost 8 years ago. Updated almost 8 years ago.

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

0%

Estimated time:

Description

The custom fields list displays the number of projects the issue custom field is used in by doing a database query for each custom field:

custom_field.projects.count

To improve the performance dramatically when there are really lots of issue custom fields the counts should be pre-loaded with a single database query:

@custom_fields_projects_count = IssueCustomField.where(is_for_all: false).joins(:projects).group(:custom_field_id).count

In the view the counts can then be accessed by:

@custom_fields_projects_count[custom_field.id]

A patch file is attached.

Regards,
Thomas


Files

custom_fields_projects_count.diff (1.65 KB) custom_fields_projects_count.diff Thomas Löber, 2016-12-12 13:56
Actions

Also available in: Atom PDF