social icon indicating copy to clipboard operation
social copied to clipboard

[14.0][IMP] mail_tracking: add job to delete old tracking records

Open henrybackman opened this issue 1 year ago • 6 comments

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.

henrybackman avatar Aug 08 '24 08:08 henrybackman

Do you have some metrics about performance degradation that leads to this action?

pedrobaeza avatar Aug 08 '24 09:08 pedrobaeza

@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)

sebalix avatar Aug 08 '24 11:08 sebalix

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.

pedrobaeza avatar Aug 08 '24 11:08 pedrobaeza

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:

henrybackman avatar Aug 08 '24 11:08 henrybackman

Test added to the tests/__init__.py and improved wording in the settings description

henrybackman avatar Aug 09 '24 11:08 henrybackman

@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:

simahawk avatar Aug 09 '24 12:08 simahawk

@pedrobaeza good for you?

simahawk avatar Aug 26 '24 14:08 simahawk

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). 🤖

OCA-git-bot avatar Aug 26 '24 14:08 OCA-git-bot

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.

OCA-git-bot avatar Aug 26 '24 14:08 OCA-git-bot

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

OCA-git-bot avatar Aug 26 '24 14:08 OCA-git-bot