Automatically deleting 'old' data from Raspberry Pi

I've had Emoncms running on a Raspberry Pi since November and it has gradually ground to a halt due to the size of the database (nearly 1Gbyte). Since I'm only really interested in recent data I would like to automatically delete all records that are more than say 1 month old.

Firstly is there a way to do this in Emoncms? (seems to me that everyone must have the same problem but I can't see a way to do this)

Failing that has anyone written a script that I can copy to do this?

My last resort will be to do this myself. I know very little about MySQL or PHP but given enough time I think I could work it out. I presume it would require a cron entry to run daily, which would in turn run a PHP script to access all feeds in the database and remove all entries that have a time value that is less than the UNIX time for one month ago.

Incidentally, I just tried deleting the rows from one feed with "delete from feed_4 where time<1361273400;" and it took 20 minutes to delete 800,000 rows!

Jérôme's picture

Re: Automatically deleting 'old' data from Raspberry Pi

This is an interesting point.

To my knowledge, this has not been addressed (yet). I might be wrong.

How is this dealt with on emoncms.org ?

Ideally, a per input / per feed setting would be nice : you may want to keep averages for several years, but you don't need all samples. Just thinking out loud.

mattnj's picture

Re: Automatically deleting 'old' data from Raspberry Pi

someone needs to ad rrdgraphs to it.

i dont have the skills or i would.

its opensource and is exactly for this situation.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.