After I REPAIR
OPTIMIZE
ANALYZE
OR CHECK
a table, do I need to FLUSH
it?
FLUSH PRIVILEGES is really needed if we modify the grant tables directly using such as INSERT, UPDATE or DELETE, the changes have no effect on privileges checking until we either restart the server or tell it to reload the tables.
The idea of FLUSH TABLES is to force all tables to be closed. This is mainly to ensure that if someone adds a new table outside of MySQL (for example, by copying files into a database directory with cp ), all threads will start using the new table.
To execute FLUSH , you must have the RELOAD privilege.
To tell the server to reload the grant tables, perform a flush-privileges operation. This can be done by issuing a FLUSH PRIVILEGES statement or by executing a mysqladmin flush-privileges or mysqladmin reload command.
A flush is not necessary.
When it comes to ANALYZE TABLE or CHECK TABLE, they just read the table. ANALYZE
will write index statistics elsewhere.
When it comes to REPAIR TABLE or OPTIMIZE TABLE, they perform full DDL by copying the MyISAM table to a temp table and then renaming the table back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With