I have a PC with a small disk:
Filesystem Size Used Avail Use% Mounted on
/dev/root 3.5G 3.1G 249M 93% /
devtmpfs 459M 0 459M 0% /dev
tmpfs 463M 0 463M 0% /dev/shm
tmpfs 463M 36M 428M 8% /run
tmpfs 5.0M 8.0K 5.0M 1% /run/lock
tmpfs 463M 0 463M 0% /sys/fs/cgroup
/dev/mmcblk0p1 63M 25M 38M 40% /boot
tmpfs 64M 140K 64M 1% /mnt/ramdisk
I have a simple database, but one of the tables has more than 5 million rows, taking up a lot on such a small record:
# ls -lh /var/lib/mysql/datalogger/
total 1.1G
...
-rw-rw---- 1 mysql mysql 1.1G Nov 10 09:56 avg_values.ibd
...
My goal, done on other similar computers without so much space occupied (about half in that table) was to run a query that deleted data more than 6 months old. The query is irrelevant to the case. after the query, running optimize NO_WRITE_TO_BINLOG table avg_values; free up ibd space.
The problem with the computer in question, is that -as I believe- the available space is very limited, you can not perform queries on such a large table (by cache, I understand), causing instability in communications, even when the query has a limit:
MariaDB [datalogger]> select * from avg_values limit 10;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 5
Current database: datalogger
ERROR 2013 (HY000): Lost connection to MySQL server during query
With other smaller tables there are usually no problems (although it also indicates error):
MariaDB [datalogger]> select * from raw_values;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id: 5
Current database: datalogger
+----+---------------------+-------------------+------+-------+
| id | timestamp | channel | raw | value |
+----+---------------------+-------------------+------+-------+
| 1 | 2021-11-10 09:46:51 | AI1 | 1 | 0.011 |
| 2 | 2021-11-10 09:46:51 | AI2 | 1 | 0.011 |
| 3 | 2021-11-10 09:46:51 | AI3 | 2 | 0.022 |
| 4 | 2021-11-10 09:46:51 | AI4 | 2 | 0.022 |
| 5 | 2021-11-10 09:46:51 | pyr1_sensor1_data | 113 | 113 |
| 6 | 2021-11-10 09:46:51 | pyr1_body_temp | 42 | 42 |
| 7 | 2021-11-10 09:46:51 | pyr2_sensor1_data | NULL | NULL |
| 8 | 2021-11-10 09:46:51 | pyr2_body_temp | NULL | NULL |
| 9 | 2021-11-10 09:46:46 | AI1 | 1 | 0.011 |
| 10 | 2021-11-10 09:46:46 | AI2 | 1 | 0.011 |
| 11 | 2021-11-10 09:46:46 | AI3 | 2 | 0.022 |
| 12 | 2021-11-10 09:46:46 | AI4 | 2 | 0.022 |
| 13 | 2021-11-10 09:46:46 | pyr1_sensor1_data | 115 | 115 |
| 14 | 2021-11-10 09:46:46 | pyr1_body_temp | 42 | 42 |
| 15 | 2021-11-10 09:46:46 | pyr2_sensor1_data | NULL | NULL |
| 16 | 2021-11-10 09:46:46 | pyr2_body_temp | NULL | NULL |
| 17 | 2021-11-10 09:46:52 | AI1 | 1 | 0.011 |
| 18 | 2021-11-10 09:46:52 | AI2 | 1 | 0.011 |
| 19 | 2021-11-10 09:46:52 | AI3 | 2 | 0.022 |
| 20 | 2021-11-10 09:46:52 | AI4 | 2 | 0.022 |
| 21 | 2021-11-10 09:46:52 | pyr1_sensor1_data | 112 | 112 |
| 22 | 2021-11-10 09:46:52 | pyr1_body_temp | 42 | 42 |
| 23 | 2021-11-10 09:46:52 | pyr2_sensor1_data | NULL | NULL |
| 24 | 2021-11-10 09:46:52 | pyr2_body_temp | NULL | NULL |
+----+---------------------+-------------------+------+-------+
24 rows in set (0.02 sec)
Is there any way I can run these queries, especially with this little disk in order to free up space?
SELECTs on the large table work on a PC with enough space?