Project

General

Profile

Actions

Patch #37057

closed

Query optimization for attachments activity

Added by Jens Krämer over 2 years ago. Updated over 2 years ago.

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

0%

Estimated time:

Description

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 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.


Files

0001-Attachment-activity-provider-sql-optimization.patch (1.06 KB) 0001-Attachment-activity-provider-sql-optimization.patch Jens Krämer, 2022-04-28 13:34
attachment2.patch (493 Bytes) attachment2.patch Pavel Rosický, 2022-04-28 18:21
37057.patch (813 Bytes) 37057.patch Go MAEDA, 2022-04-30 09:48
Actions

Also available in: Atom PDF