Most of the stuff you'll find about mysql tuning on the web has a tendency to focus on the server wide parameters you can adjust. However its important to realize that this isn't the whole picture, and in fact I suggest that you wait until after you are reasonably sure that your queries and indexes are well tuned before worrying about the server wide parameters. This is because tuning the queries and indexes can have a massive effect on the values you need to use for the server's parameters.

I have touched before on adding indexes to your tables, and how to make sure that your queries are making good use of those indexes, however I perhaps haven't explained why this matters so much.

To understand you have to realize what the 'rows' column when using the EXPLAIN command means in relation to using memory. Each row that shows up when using the EXPLAIN command is a row that mysql has to put into memory when running the query. Worse, if you are joining multiple tables then you have to multiply the 'rows' values together (as this page explains in its example near the bottom of the page). This means that if your query is taking 100 rows from one table, and joining those with 350 rows from a second table, mysql is going to need enough memory for 35,000 rows of information in memory.

Using the slow query log to find queries that aren't performing as well as they should, and then using the EXPLAIN command to tune those queries, I have seen the number of rows mysql needs to read from a table drop from 5000+ to under 20. That's 250 times fewer rows retrieved from a single table, which means 250 times less memory was needed to run the optimized query. If server wide parameters like key_buffer_size or query_cache_size were optimized before the query itself was optimized, then your mysql installation would be configured to use excessive amounts of memory, leaving other processes shortchanged. This is why its important to tune your queries first, and then if there are still problems after tuning the queries, that's when you look at the server wide parameters.