プロジェクト

全般

プロフィール

Vote #81928

未完了

query optimization for attachments activity

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

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

0%

予定工数:
category_id:
53
version_id:
176
issue_org_id:
37057
author_id:
40856
assigned_to_id:
0
comments:
3
status_id:
1
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[New]

説明

The @LEFT JOIN@ with an @OR@ in its clause in the first @acts_as_activity_provider@ call in @attachment.rb@ can cause very long query times for large numbers of attachments (on MySQL, at least).

One example we observed was on Users#show, where the query for activity on version / project attachments took 30 seconds (and yielded zero results) for a user that authored over 100k attachments (but none of them were attached to versions or projects).

This patch that was extracted from "Planio":https://plan.io/redmine-hosting adds a where clause that limits the number of attachments that are at all considered for the joins to those that are actually attached to a version or project.


journals

nice optimization, I think we could use the same trick on Documents
--------------------------------------------------------------------------------
Setting the target version to 5.1.0.
--------------------------------------------------------------------------------
Pavel Rosický wrote:
> nice optimization, I think we could use the same trick on Documents

Technically yes. However, as the joins used there are a straight line there (@attachments@ -> @documents@ -> @projects@), MySQL's query optimizer already chooses a fast query plan in this case. As such, we have not observed any significant speedup there when using the additional restriction.

With that being said, it likely won't hurt either :)
--------------------------------------------------------------------------------

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

  • カテゴリPerformance_53 にセット
  • 対象バージョン5.1.0_176 にセット

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

いいね!0
いいね!0