Linux – Configure MySQL server to minimize disk usage

configurationlinuxMySQL

I have a Raspberry PI computer with some measurement device and a script that takes a measurement every five minutes and stores the result in MySQL database. I have configured MySQL server to keep the database on external USB HDD in order to minimize wear on the SD card used as root filesystem in Rpi.

Entire data saved on my HDD every five minutes consists of only a few numbers – two numbers as a result, timestamp and id as primary key for MySQL table – and yet MySQL server keeps writing it out to the disk every time a new data is available. This causes the disk to spin-up every five minutes, which increases power usage and wears down the HDD. Is there a way to configure MySQL to cache some data in RAM until it has enough of it to write to HDD? I assume the default configuration is optimized for large quantities of data in short periods and reliability in case of eg. power failure, but I actually don't care about either of those. Even if a power failure occurs (rather unlikely) it will not be a problem if I miss a few results more than necessary anyway.

I have looked into MySQL documentation and googled for it, but all resources concerning MySQL and disk usage seem to concentrate on increasing HDD throughput or optimizing it for quick response times.

In case it's important, mysqld -V returns:

mysqld  Ver 5.5.46-0+deb7u1 for debian-linux-gnu on armv7l ((Debian))

EDIT:

I do realize that I am using MySQL a bit like a golden hammer here – MySQL was never written with my kind of application in mind. Perhaps somebody could propose an alternative solution to my problem that would require similar amount of work to setup.

Best Answer