Add an index on attachments.disk_filename
|Assignee:||Jean-Philippe Lang||% Done:|
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.