mysql -u root -p -e "OPTIMIZE TABLE appdb.users;"

Category: Databases & SQL

mysql -u root -p -e "OPTIMIZE TABLE appdb.users;"

Rebuild and defragment a table

Rebuilds the users table, reclaiming fragmented space and refreshing statistics. It locks the table during the rebuild, so run it in a maintenance window. InnoDB tables usually need this only after heavy churn.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.