Forums

Optimize table (MySQL)

Hi. It's been years that I am using flask-sqlalchemy to handle my db.

I was doing some clean-up via cron tasks, daily.

But I just discovered recently that my db has grown up to 1.7GB.

It appears that I need to run OPTIMIZE TABLE mytable; SQL command to force MySQL to reclaim the space and free it up.

I wonder if there is something that I should have done at the sqlachemy level; what I have found, so far, is that it does not seem so.

So then, shouldn't this be in the doc or the FAQ on the site here? I don't think I have seen.

I am told that one can also use a "null" ALTER TABLE operation like said on https://dev.mysql.com/doc/refman/8.0/en/innodb-file-defragmenting.html

It's impossible for us to debug your sql alchemy configuration.