Open dr-yd opened 2 years ago
@dr-yd Thanks for the PR! We'll take a look at this for our next release.
Our server hasn't been brought down, but we're experiencing lots of database errors with SQL statements like this one:
INSERT INTO wp_oses_email_attachments
(email_id
, attachment_id
, filename
) VALUES (311693, 31692, '
A slow update statement on the wp_oses_email_attachments would explain that error. We have ~32k records in wp_oses_attachments and wp_oses_email_attachments. I haven't tested the PR, but I'd be very glad to see improvement in this query.
Grouping by attachment ID before joining produces the same behavior as intended and reduced the query run time from 55min at 100% CPU to 700ms for our use case with 42k attachments and 130k email_attachment entries.