Skip to content

[PERF] api_log_mail: Faster attachment deletion#618

Merged
OCA-git-bot merged 1 commit into
OCA:16.0from
PyTech-SRL:16.0-imp-api_log-attachment_perf
Jun 29, 2026
Merged

[PERF] api_log_mail: Faster attachment deletion#618
OCA-git-bot merged 1 commit into
OCA:16.0from
PyTech-SRL:16.0-imp-api_log-attachment_perf

Conversation

@SirPyTech

Copy link
Copy Markdown
Contributor

When deleting an ir.attachment, all the foreing keys are inspected: if the api.log has a lot of records this could be very slow.

In our instance there are 2 million records and deleting a record takes ~500ms, after this change the same deletion takes less than 1ms.

Note that this change is not needed in future versions because in 17.0 the main attachment is moved to the dedicated mixin mail.thread.main.attachment (see odoo/odoo@f8c7f2e).

When deleting an `ir.attachment`, all the foreing keys are inspected: if the `api.log` has a lot of records this could be very slow.
In our instance there are 2 million records and deleting a record takes ~500ms, after this change the same deletion takes less than 1ms.

@HekkiMelody HekkiMelody left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review, LGTM

@quirino95 quirino95 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and functional review, LGTM

@OCA-git-bot

Copy link
Copy Markdown
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@SirPyTech

Copy link
Copy Markdown
Contributor Author

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 16.0-ocabot-merge-pr-618-by-SirPyTech-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit e9cbb4c into OCA:16.0 Jun 29, 2026
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 80a9f41. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants