You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a performance issue when viewing an Email in the EmailAdmin when there are a lot Emails and Attachments in the database. This is caused by customizing the get_queryset method of AttachmentInline to try to filter out inline attachments by their header values.
In the post_office.admin.AttachmentInline.get_queryset method, Django has not yet applied the Email FK filter to the queryset. That happens later when the inline formset is being created.
That means that the query being run in the get_queryset method actually fetches and iterates over every single Email Attachment object in the database, regardless of the Email it is for. In the loop, it also references the attachment property, but without a select_related on the query, it will have to fetch each attachment separately for every iteration.
If you have a lot of Emails and Attachments in the database, this causes performance issues.
The text was updated successfully, but these errors were encountered:
barqshasbite
added a commit
to barqshasbite/django-post_office
that referenced
this issue
Sep 19, 2022
There is a performance issue when viewing an Email in the EmailAdmin when there are a lot Emails and Attachments in the database. This is caused by customizing the
get_queryset
method ofAttachmentInline
to try to filter out inline attachments by their header values.In the
post_office.admin.AttachmentInline.get_queryset
method, Django has not yet applied the Email FK filter to the queryset. That happens later when the inline formset is being created.That means that the query being run in the
get_queryset
method actually fetches and iterates over every single Email Attachment object in the database, regardless of the Email it is for. In the loop, it also references theattachment
property, but without aselect_related
on the query, it will have to fetch each attachment separately for every iteration.If you have a lot of Emails and Attachments in the database, this causes performance issues.
The text was updated successfully, but these errors were encountered: