The Netbox database since the migration to version 3.2 (see T296452) is growing out of control at a rate of around ~300MB/day. Its compressed backups are growing at ~5MB/day.
Yesterday's expanded DB is 1.4GB in size, compared to 31 MB before the migration.
See the disk usage graph (link to live data in [1]):
Looking at the largest tables:
netbox=# SELECT nspname || '.' || relname AS "relation", pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') AND C.relkind <> 'i' AND nspname !~ '^pg_toast' ORDER BY pg_total_relation_size(C.oid) DESC LIMIT 3; relation | total_size ----------------------------+------------ public.extras_jobresult | 148 MB public.extras_objectchange | 33 MB public.dcim_interface | 5248 kB (3 rows)
It's clear that extras_jobresult is the largest one and that's due because of the getstats.GetDeviceStats job:
netbox=# select name, count(*) as count from extras_jobresult group by name order by count desc limit 3; name | count -------------------------+------- getstats.GetDeviceStats | 67193 puppetdb.PhysicalHosts | 288 accounting.Accounting | 288 (3 rows)
That I guess is run by prometheus at an unnecessary frequency, we could run it once a day.
Looking at the relations also points to the same culprit:
netbox=# SELECT nspname || '.' || relname AS "relation", pg_size_pretty(pg_relation_size(C.oid)) AS "size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') ORDER BY pg_relation_size(C.oid) DESC LIMIT 3; relation | size ------------------------------------------------------------+--------- public.extras_jobresult | 134 MB public.extras_objectchange | 29 MB pg_toast.pg_toast_19743 | 7024 kB (3 rows)