[18.0][ADD] database_size
Monitor the size of your Odoo instance.
Configuration
To configure this module, you can review the scheduled action called 'Take model size measurements' and check the time at which you want it to run. It should only run once a day. If it runs more often, it just update the existing set of sizes for the day.
Usage
You can use this module to keep an eye on the development of the size of your Odoo instance over time. Every day, a snapshot will be taken with the full size of the database and the attachments. You can query these daily snapshots, and you can compare the current size with a size at any date of the past for which there is data.
Enable debug mode, then go to menu Settings -> Technical -> Database Size.
The data that is gathered and that is displayed are:
- Model - The name of the model to which the data is related
- Estimated Rows - The number of estimated rows according to the Postgresql query planner. For performance reasons, taking the data from the planner is preferred over doing an actual count, although the results may be imprecise.
- Bare Table Size - The disk usage of the model table without indexes etc.
- Index Size - The disk usage of the indexes in the model table.
- Many2many Tables Size - The disk usage of related many2many tables, including their indexes. To prevent double counts, many2many tables are only correlated with one of their tables (the largest of the two).
- Attachment Size - The disk usage of the attachments linked to the model records. Because Odoo will deduplicate attachments by content, attachments with the same content may be counted double in the attachment size of other models, but will not be counted double then linked to records of the same model more than once.
- Total Table Size - Bare Table Size + Index Size
- Total Database Size - Total Table Size + Many2many Tables Size
- Total Model Size - Total Database Size + Attachment Size
If you click on individual records, you can inspect the sizes of each index and many2many table.
All sizes are in megabytes.
In the 'Compare Size per Model' report view, you can find these data twice: once for the selected measurement date (default: today), and once for the selected comparison date (default: one month ago).
If you want to compare arbitrary dates, you can start typing the date in the search box. Be sure to enter the dates in the right format for your localization.
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). 🤖
@legalsylvain No plans for a backport from my side.
Oh, before the merge I should probably implement @hbrunn's suggestion of the cleanup cron. Give me a couple of days.
@florian-dacosta Thanks for the suggestion! I'd like to keep this more flexible, as you mention with the option to leave the cron inactive and some parameters to configure the retention period.
@StefanRijnhart my idea was in no way meant to be blocking, so I'd be happy to merge this as is
@hbrunn No, I think it's a good idea.
Feature to purge older data is now pushed. @florian-dacosta of course I just had to use res.config.settings to configure the parameters and then I could use your suggestion after all. Thanks again!
/ocabot merge nobump
This PR looks fantastic, let's merge it! Prepared branch 18.0-ocabot-merge-pr-3275-by-legalsylvain-bump-nobump, awaiting test results.
Congratulations, your PR was merged at 762695963d8513cb4eb9813baa41fb181c20d663. Thanks a lot for contributing to OCA. ❤️
@vdewulf : I think this module is very interesting for people with huge instances. maybe some communication in the next newsletter could be great, to promote it.
@vdewulf : I think this module is very interesting for people with huge instances. maybe some communication in the next newsletter could be great, to promote it.
Sure!