How to clear or shrink Zigbee (zha) Database

The file containing my zha database has grown to 370 MB. Is this size normal? I was wondering if there’s a ‘correct’ way to shrink the database size.

I initially attempted to change the existing “database_path: /config/zigbee.db” to “database_path: /config/zigbee_new.db”. This created a new file and it appeared to somewhat work - the only issue is that most of my Zigbee devices continued to stay “unavailable” to me. Only a handful of devices came back online and were controllable.

1 Like

sounds pretty large my zigbee.db is 608kb i have about 38 items paired directly through zha

So it turns out the “Attributes” table in my SQL lite file was bursting at the seams. Why… I don’t know. Anyhow, here’s how I got my size down from the 370 MB file:

Download DB Browser for SQL Lite
Run the following command in the “Execute SQL” window: DELETE FROM Attributes
Once complete, go to Tools → Compact Database.

My Zigbee.db file is now 200 KB. As far as I can tell, all devices appear to be responding as they normally would. My Home Assistant load time has drastically improved. I had an earlier update problem where home assistant would report a corrupted zigbee.db file - that seems to have been fixed as well.

1 Like