# How do I fix the "Out of sort memory" error? ``` ERROR 1038 (HY001): Out of sort memory, consider increasing server sort buffer size ``` [Sort Buffer Size (`sort_buffer_size`)](https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sort_buffer_size) is a MySQL server system variable that can affect your query performance. It is defined on a per-session level, impacting your cluster’s memory consumption. **Warning**: Changing `sort_buffer_size` can reduce query performance, increase overall memory consumption, and even crash your cluster. This process is highly specific to your workload and we do not recommend changing the default value. Please read [its potential use cases and disclaimers](https://docs.digitalocean.com/products/databases/mysql/concepts/sort-buffer-size/index.html.md#use-cases) before changing it. To fix this error, increase `sort_buffer_size` to a value higher than its default of 256 KB. Having `sort_buffer_size` over 5 MB may significantly slow down memory allocation. To learn how to safely adjust `sort_buffer_size`, see [our guide](https://docs.digitalocean.com/products/databases/mysql/concepts/sort-buffer-size/index.html.md). ## Related Topics [How do I fix the mysqldump "Couldn't execute FLUSH TABLES Access denied" error?](https://docs.digitalocean.com/support/how-do-i-fix-the-mysqldump-couldnt-execute-flush-tables-access-denied-error/index.html.md): Update backup user permissions, remove the –single-transaction flag, or downgrade mysqldump. [Why does MySQL shut down when importing data with the source command?](https://docs.digitalocean.com/support/why-does-mysql-shut-down-when-importing-data-with-the-source-command/index.html.md): Use MySQL’s import command instead of source for handling large data imports. [How do I fix the "1227" error?](https://docs.digitalocean.com/support/how-do-i-fix-the-1227-error/index.html.md): Remove or replace the DEFINER in the dump file.