I got fully immersed in performance tuning on the databases at work this morning. There was a seriously overloaded MySQL machine. No time like a crisis to have the new guy try his hand at resolving a performance issue. I was in a meeting for part of the time where I couldn't do much more than watch and I noticed over time that there were anywhere from 2 to 10 queries stuck writing to temp tables. This was happening over and over for more than an hour. Somewhere halfway through the meeting a query came through that was taking many minutes, mostly stuck in a mode of writing to a temp table.
Upon further inspection I noticed that the myisam_sort_buffer_size was set fairly large, but the sort_buffer_size was quite small. To my knowledge, the myisam_sort_buffer_size is for table maintenance and optimization, but isn't used during normal database operations. The sort_buffer_size is used for sorting for normal operations. After getting consensus …
[Read more]