Best option is create new table with same properties
CREATE TABLE <NEW.NAME.TABLE> LIKE <TABLE.CRASHED>;
INSERT INTO <NEW.NAME.TABLE> SELECT * FROM <TABLE.CRASHED>;
Rename NEW.NAME.TABLE and TABLE.CRASH
RENAME TABLE <TABLE.CRASHED> TO <TABLE.CRASHED.BACKUP>;
RENAME TABLE <NEW.NAME.TABLE> TO <TABLE.CRASHED>;
After work well, delete
DROP TABLE <TABLE.CRASHED.BACKUP>; - działało do 17GB, potem się zawiesiło. Szybsze i łatwiejsze jest opisane niżej
ALTER TABLE tbl_name ENGINE=INNODB.
https://stackoverflow.com/questions/30635603/what-does-table-does-not-support-optimize-doing-recreate-analyze-instead-me
Defragmenting a Table:
One symptom of fragmentation is that a table takes more space than it “should” take.
To speed up index scans, you can periodically perform a “null” ALTER TABLE
operation, which causes MySQL to rebuild the table:
ALTER TABLE tbl_name ENGINE=INNODB - działa! Baza danych zmniejszyła się z 32GB do 25 GB. Czas około 30 minut, potrzebne było tymczasowo 25 GB miejsca na dysku.
You can also use
ALTER TABLE tbl_name
FORCE
to perform a“null” alter operation that rebuilds the table.
Another way to perform a defragmentation operation is to use mysqldump to dump the table to a text file, drop the table, and reload it from the dump file.
If the insertions into an index are always ascending and records are deleted only from the end, the InnoDB
filespace management algorithm guarantees that fragmentation in the index does not occur.
https://dev.mysql.com/doc/refman/5.7/en/innodb-file-defragmenting.html