Table Maintenance

Table Maintenance: ANALYZE, CHECK, OPTIMIZE, and REPAIR

Four statements look after a table's physical storage, and InnoDB changes what three of them do:

Refreshing statistics and rebuilding an InnoDB tableSQL
ANALYZE TABLE orders;
OPTIMIZE TABLE orders\G
Output
+-------------+---------+----------+----------+
| Table       | Op      | Msg_type | Msg_text |
+-------------+---------+----------+----------+
| shop.orders | analyze | status   | OK       |
+-------------+---------+----------+----------+
*************************** 1. row ***************************
   Table: shop.orders
      Op: optimize
Msg_type: note
Msg_text: Table does not support optimize, doing recreate + analyze instead
...

mysqlcheck --analyze --all-databases runs them from cron (Cron, Logs and journalctl).