(mysql.info) maintenance-schedule
Info Catalog
(mysql.info) table-info
(mysql.info) table-maintenance
5.10.4.6 Setting Up a Table Maintenance Schedule
................................................
It is a good idea to perform table checks on a regular basis rather
than waiting for problems to occur. One way to check and repair
`MyISAM' tables is with the `CHECK TABLE' and `REPAIR TABLE'
statements. See check-table, and repair-table.
Another way to check tables is to use `myisamchk'. For maintenance
purposes, you can use `myisamchk -s'. The -s option (short for -silent)
causes `myisamchk' to run in silent mode, printing messages only when
errors occur.
It is also a good idea to enable automatic `MyISAM' table checking. For
example, whenever the machine has done a restart in the middle of an
update, you usually need to check each table that could have been
affected before it is used further. (These are `expected crashed
tables.') To check `MyISAM' tables automatically, start the server with
the -myisam-recover option. See server-options.
You should also check your tables regularly during normal system
operation. At MySQL AB, we run a `cron' job to check all our important
tables once a week, using a line like this in a `crontab' file:
35 0 * * 0 /PATH/TO/MYISAMCHK --fast --silent /PATH/TO/DATADIR/*/*.MYI
This prints out information about crashed tables so that we can examine
and repair them when needed.
Because we have not had any unexpectedly crashed tables (tables that
become corrupted for reasons other than hardware trouble) for several
years, once a week is more than sufficient for us.
We recommend that to start with, you execute `myisamchk -s' each night
on all tables that have been updated during the last 24 hours, until
you come to trust MySQL as much as we do.
Normally, MySQL tables need little maintenance. If you are performing
many updates to `MyISAM' tables with dynamic-sized rows (tables with
`VARCHAR', `BLOB', or `TEXT' columns) or have tables with many deleted
rows you may want to defragment/reclaim space from the tables from time
to time. You can do this by using `OPTIMIZE TABLE' on the tables in
question. Alternatively, if you can stop the `mysqld' server for a
while, change location into the data directory and use this command
while the server is stopped:
shell> myisamchk -r -s --sort-index --sort_buffer_size=16M */*.MYI
Info Catalog
(mysql.info) table-info
(mysql.info) table-maintenance
automatically generated byinfo2html