Server System Variables Scope Global Dynamic No SET_VAR  Hint Applies No Type String Default Value (Windows) MySQL Default Value (Other) /tmp/mysql.sock Command-Line Format --sort-buffer-size=# System Variable sort_buffer_size Scope Global, Session Dynamic Yes SET_VAR  Hint Applies Yes Type Integer Default Value 262144 Minimum Value 32768 Maximum Value (Windows) 4294967295 Maximum Value (Other, 64-bit platforms) 18446744073709551615 Maximum Value (Other, 32-bit platforms) 4294967295 884 The maximum permissible setting for  sort_buffer_size  is 4GB − 1. Larger values are permitted for 64-bit platforms (except 64-bit Windows, for which large values are truncated to 4GB − 1 with a warning). The optimizer tries to work out how much space is needed but can allocate more, up to the limit. Setting it larger than required globally slows down most queries that perform sorts. It is best to increase it as a session setting, and only for the sessions that need a larger size. On Linux, there are thresholds of 256KB and 2MB where larger values may significantly slow down memory allocation, so you should consider staying below one of those values. Experiment to find the best value for your workload. See Section B.3.3.5, “Where MySQL Stores Temporary Files” . If you see many  Sort_merge_passes  per second in  SHOW GLOBAL STATUS  output, you can consider increasing the  sort_buffer_size  value to speed up  ORDER BY  or  GROUP BY  operations that cannot be improved with query optimization or improved indexing. Each session that must perform a sort allocates a buffer of this size.  sort_buffer_size  is not specific to any storage engine and applies in a general manner for optimization. At minimum the sort_buffer_size  value must be large enough to accommodate fifteen tuples in the sort buffer. Also, increasing the value of  max_sort_length  may require increasing the value of  sort_buffer_size . For more information, see Section 8.2.1.16, “ORDER BY Optimization” On Windows, this variable is the name of the named pipe that is used for local client connections. The default value is  MySQL  (not case-sensitive). • sort_buffer_size On Unix platforms, this variable is the name of the socket file that is used for local client connections. The default is  /tmp/mysql.sock . (For some distribution formats, the directory might be different, such as  /var/lib/mysql  for RPMs.)