Database suddenly became 3 times bigger within a day

Two weeks ago I noticed that my database (standard) suddenly increased.
It happened at night between 22:00 16.10.22 and 04:00 17.10.22.

изображение

There was nothing happening with HA this period.
No updates were installed before/during this time, no any user’s activity.
Probably it happened due to a large CPU load within these hours.

I noticed it when I realized next day that my “watchdog” telegram notifications (every hour) do not come.
Opened a console, ran “top” and realized a huge load by “pithon3” process.
A similar huge load I observe rather often, at least 2-3 time a week.
Have no time to find out a reason of these spikes. Gonna do it some day. Meanwhile I just restart HA when it happens.

Now I want to reduce a DB size. I suspect some damage, invalid data etc.
Surely I can just delete a db file - but do not want to loose a statistics.

Is it possible to fix it somehow?

The time when it happened I had 2022.10.3.
HA in Container.

This post gives some tips on how to find what is using the space. What is your purge_keep_days set to? Unless it’s over 3 weeks I would expect the old data to have been purged (and long term statistics shouldn’t be taking up all that space).

1 Like

I did that optimization at the beginning of my HA setup, excluded some entities (did not use “include”).
Usually the DB size keeps same - unless I add new entities or update HA / plugins.
I have not observed any sudden growth of DB so far (for 2 years).
The “purge_keep_days” is 10.
The only reason I suspect is a CPU huge load (python) - probably DB was not able to operate.

I was basically interested in “how to fix DB, how to remove junk etc”.
Finally I surrendered and just deleted DB (stop HA - delete *.db* - start HA).