Vote #81797
完了Reduce database queries when rendering Custom fields box in the project settings tab
開始日:
2022/05/09
期日:
進捗率:
0%
予定工数:
Redmineorg_URL:
category_id:
53
version_id:
155
issue_org_id:
36505
author_id:
332
assigned_to_id:
332
comments:
3
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
説明
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
journals
Setting the target version to 5.0.0.
--------------------------------------------------------------------------------
Committed the patch.
--------------------------------------------------------------------------------
いいね!0