Recently, a heavy burst of traffic into our production webservice caused this error. As with all Mysql errors, this shows little information. Like any sane person would think, we checked if the filesystem was full. We found the /tmp has 98% free space. Permissions are all fine. No locks on table. Increasing /tmp partition - NoGo. Just crazy error message.
However, the issue was beating us time and again. It took us a couple of days and we realized the cause was a select query. The query was fetching from a table of about 2 million records. Although it was fetching a limited subset, the column in the order by had no index. This was causing mysql to load records into pagefile in tmp for sorting, apparently.
Created the index on the sort column seemed to have solved the problem. We also augmented it with the following options in my.cfg
However, the issue was beating us time and again. It took us a couple of days and we realized the cause was a select query. The query was fetching from a table of about 2 million records. Although it was fetching a limited subset, the column in the order by had no index. This was causing mysql to load records into pagefile in tmp for sorting, apparently.
Created the index on the sort column seemed to have solved the problem. We also augmented it with the following options in my.cfg
sort_buffer_size=2M table_cache=1800 thread_cache_size=384 tmp_table_size=64M