Mysql - Shink table after delete
For a &quot;large&quot; delete (more than, say, half the table), do something like:
CREATE TABLE new LIKE real;
INSERT INTO new
    SELECT * FROM real WHERE ...  -- what to keep
RENAME TABLE real TO old,
             new TO real;
DROP TABLE old;

The INSERT..SELECT is slow; the other steps are fast.  No need to &quot;shrink&quot; unless the original table was created with innodb_file_per_table=OFF, in which case the disk usage will increase with this process.
More big-delete tips for more cases:  http://mysql.rjweb.org/doc.php/deletebig