Patch #25022

Add an index on attachments.disk_filename

Added by Jens Krämer 7 months ago. Updated 6 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Performance
Target version:3.4.0

Description

In a system with lots of attachments deleting one attachment can take very long due to the DB lookup in Attachment#delete_from_disk which checks if the same physical file is used by any other attachment.

We had this issue at Planio in a setup with more than 500k attachments, where deleting a single one could take up to half a second. This patch adds an index on attachments.disk_filename that fixed the issue for us.

0001-adds-an-index-to-attachments.disk_filename.patch Magnifier (1.01 KB) Jens Krämer, 2017-02-07 08:20

Associated revisions

Revision 16352
Added by Jean-Philippe Lang 6 months ago

Adds an index to attachments.disk_filename (#25022).

Patch by Jens Kraemer.

History

#1 Updated by Go MAEDA 7 months ago

  • Category set to Performance
  • Target version set to 3.4.0

Thanks for sharing the experience and the patch.
Setting target version to 3.4.0.

Attachment#delete_from_disk: source:tags/3.3.2/app/models/attachment.rb#L145

#2 Updated by Jean-Philippe Lang 6 months ago

  • Subject changed from add an index on attachments.disk_filename to Add an index on attachments.disk_filename
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang

That should be usefull indeed, thanks.

Also available in: Atom PDF