A Quick Way to Help Optimise MySQL Databases
by Simon. Average Reading Time: less than a minute.
Generally, if you want to analyse a MySQL table you can use the following command.
ANALYZE TABLE table_name
However, this doesn’t give you much information beyond “status=OK”.
Alternatively, the ANALYSE() procedure built into MySQL can give you a wealth of information about your database tables, making it easy to find out which tables need optimising.
SELECT * FROM table_name PROCEDURE ANALYSE()
NB. change table_name to be your desired table name…obviously! Oh and “analyse” is the English (UK) spelling.
You’ll get a number of results back including the minimum/maximum value, minimum/maximum length, number of empty or zero strings, number of nulls, the average value/length, the standard deviation, and a suggested optimal field type for every row in the queried table.
Of course, optimising your tables isn’t necessarily that helpful if you don’t have much data. Furthermore, optimisation isn’t simply a case of running the OPTIMIZE TABLE function on each of your tables.
