Feature #36505

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

Added by Go MAEDA 8 months ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Performance
Target version:5.0.0
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

reduce-database-query-project-settings.patch Magnifier (1007 Bytes) Go MAEDA, 2022-01-23 13:55

Associated revisions

Revision 21411
Added by Go MAEDA 7 months ago

Reduce database queries when rendering Custom fields box in the project settings tab (#36505).

Patch by Go MAEDA.

History

#1 Updated by Go MAEDA 8 months ago

  • Target version set to 5.0.0

Setting the target version to 5.0.0.

#2 Updated by Go MAEDA 7 months ago

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

Committed the patch.

#3 Updated by Go MAEDA 6 months ago

  • Tracker changed from Patch to Feature

Also available in: Atom PDF