Project

General

Profile

Actions

Feature #36505

closed

Reduce database queries when rendering Custom fields box in the project settings tab

Added by Go MAEDA about 2 years ago. Updated almost 2 years ago.

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

0%

Estimated time:
Resolution:

Description

Currently, rendering Custom fields box in the project settings tab generates SQL statements as many as the number of available issue custom fields. The attached patch improves the code to generate only one SQL statement.

Before:

  IssueCustomField Exists? (0.3ms)  SELECT 1 AS one FROM "custom_fields" WHERE "custom_fields"."type" = ? AND (is_for_all = 1 OR id IN (S
ELECT DISTINCT cfp.custom_field_id FROM custom_fields_projects cfp WHERE cfp.project_id = 1)) AND "custom_fields"."id" = ? LIMIT ?  [["ty
pe", "IssueCustomField"], ["id", 2], ["LIMIT", 1]]
  ↳ app/views/projects/settings/_issues.html.erb:26
  IssueCustomField Exists? (0.3ms)  SELECT 1 AS one FROM "custom_fields" WHERE "custom_fields"."type" = ? AND (is_for_all = 1 OR id IN (S
ELECT DISTINCT cfp.custom_field_id FROM custom_fields_projects cfp WHERE cfp.project_id = 1)) AND "custom_fields"."id" = ? LIMIT ?  [["ty
pe", "IssueCustomField"], ["id", 1], ["LIMIT", 1]]
  ↳ app/views/projects/settings/_issues.html.erb:26
  IssueCustomField Exists? (0.2ms)  SELECT 1 AS one FROM "custom_fields" WHERE "custom_fields"."type" = ? AND (is_for_all = 1 OR id IN (S
ELECT DISTINCT cfp.custom_field_id FROM custom_fields_projects cfp WHERE cfp.project_id = 1)) AND "custom_fields"."id" = ? LIMIT ?  [["ty
pe", "IssueCustomField"], ["id", 6], ["LIMIT", 1]]
  ↳ app/views/projects/settings/_issues.html.erb:26
  IssueCustomField Exists? (0.2ms)  SELECT 1 AS one FROM "custom_fields" WHERE "custom_fields"."type" = ? AND (is_for_all = 1 OR id IN (S
ELECT DISTINCT cfp.custom_field_id FROM custom_fields_projects cfp WHERE cfp.project_id = 1)) AND "custom_fields"."id" = ? LIMIT ?  [["ty
pe", "IssueCustomField"], ["id", 8], ["LIMIT", 1]]
  ↳ app/views/projects/settings/_issues.html.erb:26
  IssueCustomField Exists? (0.3ms)  SELECT 1 AS one FROM "custom_fields" WHERE "custom_fields"."type" = ? AND (is_for_all = 1 OR id IN (S
ELECT DISTINCT cfp.custom_field_id FROM custom_fields_projects cfp WHERE cfp.project_id = 1)) AND "custom_fields"."id" = ? LIMIT ?  [["ty
pe", "IssueCustomField"], ["id", 9], ["LIMIT", 1]]
  ↳ app/views/projects/settings/_issues.html.erb:26

After:

   (0.3ms)  SELECT "custom_fields"."id" FROM "custom_fields" WHERE "custom_fields"."type" = ? AND (is_for_all = 1 OR id IN (SELECT DISTIN
CT cfp.custom_field_id FROM custom_fields_projects cfp WHERE cfp.project_id = 1)) ORDER BY "custom_fields"."position" ASC  [["type", "Iss
ueCustomField"]]
  ↳ app/views/projects/settings/_issues.html.erb:24


Files

Actions #1

Updated by Go MAEDA about 2 years ago

  • Target version set to 5.0.0

Setting the target version to 5.0.0.

Actions #2

Updated by Go MAEDA about 2 years ago

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

Committed the patch.

Actions #3

Updated by Go MAEDA almost 2 years ago

  • Tracker changed from Patch to Feature
Actions

Also available in: Atom PDF