Recorder purges history partially only?

Just accidentaly checking some of the entities history I come across strange issue with recorder. I have HA configured to use Maria DB, that runs on Synology NAS in docker (not official package as I updated version to be inline with HA recommendation). Purge is set to 30 days. Recently checking the history graphs for some of my sensors, I noticed that for some of these history is not purged, but kept for ~1 year (at least for now). Here is how it looks on sample history grapht for 3 months:

Upper charts show properly 1 month of data, while bottom part shows more than that (after checking this seems I can go back up to one year). My recorder is configured in the way that all entities are excluded by default and only those that I need are explicitly included. So history for shown entities should be available, but also should be purged after 30 days… Is it bug? What would be long term impact on database?

Not a bug, but a feature of the history card you are using. I can see you are using history explorer (by the lock icons on the left).

What you are seeing past the 30 days is the long term statistics for the sensors that support it. History explorer will fuse both histories by default into a single graph. So when the 30 days data end in your normal history, the card will start pulling in the long term history instead and merge it into the graph.

If you don’t like this behavior and want to see the 30 days short term history only, you can disable it as shown in the readme here (note that the readme is wrong saying that this feature is off by default, it has been turned on by default a while ago, I will have to update the readme).

Long-term statisitics are aggregated data on 5 minutes and 1 hours intervals for certain state (basically the ones you can average)
Those are never purged (afaik), but should have marginal impact on storage.

Long-term statistics is a feature of HA, not of the card (unless the card re-implement it, which I doubt)

The card he is using is automatically merging the normal history and long term statistics into a single graph, which makes it appear as one long continuous history as you scroll along it. This is why he thought the history wasn’t purged, while in reality it was. The card was just pulling the data from a different source.

Nice card, BTW.
I was looking for a “grafana-like” card for a long time. I might have found it…

Thanks for explanations! I was not aware about statistics being automatically displayed in history eplorer card, every day something new to learn!

Well, I completely dropped build in hostory dashboard for this one. Not only you can customize it exactly to your liking with entities to show, link colors to states, but also you can easily change time frame of displayed data, scroll throigh timeline and many more!