-
Step 1
Run optimize table against your tables
This command defragments a table after you have deleted a lot of rows from it. -
Step 2
Use insert delayed when you do not need instant gratification - a response instantly - when your data is written. This reduces the overall insertion impact because many rows can be written with a single disk write.
-
Step 3
use statement priorities
* Use INSERT LOW_PRIORITY when you want to give SELECT statements higher priority than your inserts.
* Use SELECT HIGH_PRIORITY to get retrievals that jump the queue. That is, the SELECT is executed even if there is another client waiting. -
Step 4
Use multiple-row INSERT statements to store many rows with one SQL statement.
-
Step 5
Don't use complex permissions. The more complex your permissions setup, the more overhead you have. Try using simple GRANT statements to reduce the overhead looking up and applying permissions will cause.
-
Step 6
When analyzing query performance, it's also useful to consider the EXPLAIN keyword. This keyword, when placed in front of a SELECT query, describes how MySQL intends to execute the query and the number of rows it will need to process to successfully deliver a result set.
Example of usage: explain select * from table -
Step 7
Try optimizing your where clause
- Remove unnecessary parentheses
- when using "count (*)" on non myisam databases make sure you have indexes present
- make your where clauses as specific as possible -
Step 8
Use Indexes
MySQL allows you to index database tables, making it possible to quickly seek to records without performing a full table scan first and thus significantly speeding up query execution. You can have up to 16 indexes per table, and MySQL also supports multi-column indexes and full-text search indexes.
Adding an index to a table is as simple as calling the CREATE INDEX command and specifying the field(s) to index. -
Step 9
Adjust internal server variables such as key_buffer, read_buffer_size, table_cache, query_cache_size, query_cache_type, query_cache_limit and long_query_time can go a long way. There is no "right answer" for those values, so you need to play around with them. they will be different on every server.








