Anyone can tell me how to optimize the mysql tables weekly automatically? I think this can be done through cron but how...?
Ok, yes that can be done through a PHP/Perl script which have MySQL commands like OPTIMIZE TABLE table_name; Code (markup): and schedule it to run according to your need
Table will be LOCKed state when you run OPTIMIZE TABLE command on the table. OPTIMIZE TABLE should be used if you have deleted a large part of a table or if you have made many changes to a table with variable-length row (see manual). BTW, why you want to use OPTIMIZE TABLE?
Did you check the MySQL manual I told in my last post? It is only required when you are deleting a large portion of data from the table. Are you doing so?