Problem writing to Statistics table

I have this issue from day 1, but was only when I started using the energy dashboard that the problem became visible. Basically, my energy dashboard shows completely absurd data, and it turns out it is all related to the way data is written to the “statistics” table in the Home Assistant database. Instead of having a new entry every hour, or with a certain periodicity, data is written to the statistics table at completely random times (I have days with no writings, days when it was written only once and the most typical case which is five or six table entries at random, like at 5:00, 6:00, 13:00, 16:00 and 17:00).

All other tables in the database seem fine, short-term statistics table is normal.

Is there a way to manually set the write interval on the “statistics” table? What exactly is the mechanism behind the “statistics” table? Is it a periodic summary of the data contained in the short-term statistics table?

My view/experience is the other way round…short_term is ‘random’ (seems 5 mins) and statistics is hourly
From what I have seen short_term populates into statistics at the hour…but I only know my / one instance

Yes, and this is what seems to be failing, it only happens every once in a while, it should happen on every hour…

But that is what it does for as far as I am seeing… my statistics sensors seem to have an hourly update (I did not check all of course). It feeds into statistics and ‘sometimes’ it resets (don’t know why/when)

This is what my energy dashboard chart looks like from yesterday:


It should have a bar on every hour.
And here is the content of the statistics table for one of the sensors (total consumption):

Why does my statistics table not have hourly records???

Actually, just noticed that the statistics_short_term table also has an erratic behaviour, this is a sample from yesterday:

Odd indeed, this is example of my energy sensor

and this of the last entries… they all go on the hour… I have no explanation for your difference