MySQL OPTIMIZE all tables?

前端 未结 14 2104
迷失自我
迷失自我 2020-12-04 04:57

MySQL has an OPTIMIZE TABLE command which can be used to reclaim unused space in a MySQL install. Is there a way (built-in command or common stored procedure) to run this o

14条回答
  •  爱一瞬间的悲伤
    2020-12-04 05:30

    my 2cents: start with table with highest fragmentation

    for table in `mysql -sss -e "select concat(table_schema,".",table_name) from information_schema.tables where table_schema not in ('mysql','information_schema','performance_schema') order by data_free desc;"
    do
    mysql -e "OPTIMIZE TABLE $table;"
    done
    

提交回复
热议问题