I implemented this solution for big database, only keep data for 14 days (remove data daily based on date). When I run optimize TABLE table1;
The size supposes to decrease but in my case, it increases.
/etc/my.cnf
contains:
innodb_file_per_table
innodb_flush_method=O_DIRECT
innodb_log_file_size=1G
innodb_buffer_pool_size=4G
ll --block-size=GB /var/lib/mysql/mydb/
print:
-rw-r-----. 1 mysql mysql 17GB Nov 20 15:45 table1.ibd
-rw-r-----. 1 mysql mysql 5GB Nov 20 15:30 table2.ibd
-rw-r-----. 1 mysql mysql 181GB Nov 20 15:29 table3.ibd