[14.0][IMP] mail_tracking: add job to delete old tracking records
Records in mail_tracking_email table grow over time and increase the database size, which slows down backup and restore operations. (For example, in one customer db the mail_tracking_email table takes almost 2GB)
Added autovacuum to mail_tracking_email that removes by default records over 6 months old.
The deletion can be enabled with a configuration variable.
Due to possibly a large number of records to be deleted on first run, set a default limit of 5000 per run.
Do you have some metrics about performance degradation that leads to this action?
@pedrobaeza this action is here to reduce the DB size (to speed up backup and restore operations mainly), currently we have a DB with the mail_tracking_value taking almost 2GB (in the top 10 of biggest table in this DB, 8th position, 1st being mail_message).
About performance I checked but there isn't a real impact here (while this similar PR about notifications is reducing a lot the time needed to open the Odoo JS client: https://github.com/OCA/social/pull/1340)
OK, thanks for the information. It's good to add this information initially (and include it in the commit message) for avoiding to guess what is the improvement.
It would be interesting to check if there's a way to optimize the DB schema of this table to reduce this size as well. Maybe there's a related stored or similar fields that increase the size a lot.
Thank you @pedrobaeza for checking. I don't have anything to add to @sebalix comment but I added the relevant details to the description :+1:
Test added to the tests/__init__.py and improved wording in the settings description
@henrybackman when you push again pls report the description in the commit msg. Note: if you do that before opening a PR you'll get the PR description for free :wink:
@pedrobaeza good for you?
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). 🤖
What a great day to merge this nice PR. Let's do it! Prepared branch 14.0-ocabot-merge-pr-1430-by-pedrobaeza-bump-minor, awaiting test results.
Congratulations, your PR was merged at 3bd12c2e10984ae1ad70c745c946da1a4126d9d5. Thanks a lot for contributing to OCA. ❤️