プロジェクト

全般

プロフィール

Vote #73055

完了

Optimize MenuManager a bit

Admin Redmine さんが3年以上前に追加. 3年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Code cleanup/refactoring_30
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
30
version_id:
60
issue_org_id:
12721
author_id:
48958
assigned_to_id:
0
comments:
2
status_id:
5
tracker_id:
3
plus1:
1
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

In a project without the modules repository, wiki and boards, the following queries are needlessly executed:

Wiki Load (0.3ms) SELECT wikis.* FROM wikis WHERE wikis.project_id = 1 LIMIT 1
(0.5ms) SELECT COUNT() FROM boards WHERE boards.project_id = 1
Repository Load (0.7ms) SELECT repositories.
FROM repositories WHERE repositories.project_id = 1 AND (is_default = 1) LIMIT 1

In cases where issue tracking and file modules are not enabled, this is also not needed:

(0.7ms) SELECT COUNT(DISTINCT issues.id) AS count_id, tracker_id AS tracker_id FROM issues
LEFT OUTER JOIN projects ON projects.id = issues.project_id
LEFT OUTER JOIN issue_statuses ON issue_statuses.id = issues.status_id
LEFT OUTER JOIN trackers ON trackers.id = issues.tracker_id
WHERE (projects.status=1 AND projects.id IN (
SELECT em.project_id FROM enabled_modules em WHERE em.name='issue_tracking'))
AND ((projects.id = 1 OR (projects.lft > 1 AND projects.rgt < 2)))
GROUP BY tracker_id

The reason is in allowed_node? in Redmine::MenuManager::MenuHelper. It first checks extra conditions, then checks if the user is allowed to perform an action. The user permission check in turn checks if a module is enabled. The patch changes the order in which the checks are executed: First the permissions, then the extra conditions. A win of 1.5-3ms per call on my system.


journals

+1 from me.
Lesser requests for the same goal, are always a good idea. ;-)
--------------------------------------------------------------------------------
Patch committed in r11112, thanks for pointing this out.
--------------------------------------------------------------------------------

Admin Redmine さんが3年以上前に更新

  • カテゴリCode cleanup/refactoring_30 にセット
  • 対象バージョン2.3.0_60 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0