When performance tuning a MySQL application, there are five main things to consider:
SQL query tuning
Database server tuning
These are ranked in terms of “bang for the buck.” For example, adding memory or upgrading your processor will usually improve the performance of your applications, but you should be able to achieve greater gains for lower cost if you tune your application code and database server first. In addition, any performance tuning on the MySQL server will apply to all applications using that server. Characteristics that are advantageous for one particular application may not improve the performance of another. Based on these factors, as a general methodology, we recommend that you look at tuning issues in the order listed above.