alex
alex

Reputation: 490163

MySQL - The 'optimise' function?

I have noticed in phpMyAdmin you can click 'optimise' on tables, and it runs:

OPTIMIZE TABLE table_name

What does this actually do?

Should I have some cron job running daily that runs OPTIMIZE TABLE on my tables?

Thank you

Upvotes: 2

Views: 360

Answers (2)

Rob Kennedy
Rob Kennedy

Reputation: 163257

I'd start with the MySQL documentation about that command. After reading that, do you still have questions?

Upvotes: 0

Stefan Mai
Stefan Mai

Reputation: 23939

From InformIT

An optimized table structure is different than a well-designed table. Table structure optimization has to do with reclaiming unused space after deletions and basically cleaning up the table after structural modifications have been made. The OPTIMIZE SQL command takes care of this, using the following syntax:

OPTIMIZE TABLE table_name[,table_name]

Think of it like defragging your tables. A cron job might be a good idea, but do it during low/no load as it locks the tables.

Upvotes: 5

Related Questions