How to 'purge' single entities/devices -> reduce DB by 10mill rows ;)

So I have an above average interrest in data and statistics, so I have created sensors to see DB-growth thorughout my HA-journey.

When I got a zigbee-device that decided to start reporting shitloads of data, my DB grew enormously! A bit of help and investigation - and I found out that this device produced +10 mill rows of states in my DB

So with a little helpf from @tom_l and @michaelblight in this post Reduce recorder days,, keep long term statistics - #5 by ArveVM i figured I had to test how to purge single entities.

It is nothing new, but I don’t know if everyone is aware of the possibility - therefore creating this post.

So the recorder keep days is a global setting, which is run at night (04:12) or something,
But in addition to that, you can run a service to purge selected devices/entitites,
So if you do this ad-hoc, - you can easily get rid of your “hyperactive” states from a sensor

And I know this is a workaround, and I have reconfigured the sensor to not report that often - but I’d like to know how to reduce the huge amount of rows.

So if you have similar types of devices, you can put that service into an automation, much like it is presented as an option in the original documentation; Recorder - Home Assistant

So this is the way I got my DB down from +19mill to just 9mill rows, and to my friends that said “why create HAstats, its not nessesary” - I have to smile and say, you never know you know :wink:
image

1 Like

Or you could just exclude them from the recorder


Not the same, but will reduce DB size😉

1 Like

PS, you are showing exclude from logbook - not recorder, but I get your point :wink:

kinda need them, it is power-data, so need to visualize small steps in changed,
But for sure did not need it to blow way out of proportions like it did, :slight_smile: Guess it was a z2m update or something that triggered around a reporting pr second for 12 entities on one device, giving me more than a doubling of DB size.