How to fix 1038 out of sort memory by increasing sort buffer size?

0
How to fix 1038 out of sort memory by increasing sort buffer size?
5 (100%) 1 vote

Some time, when you save an articles, a post or what ever, you saw a message : “Out of sort memory, consider increasing sort buffer size”. The fun is it show that error message but data still save in database and you are not losing anything. Anyway, you want to fix this error, and hope it will never show that error again. So, in this post, Bien Thuy will help you fix this error and i’m sure you will never see message: “Out of sort memory, consider increasing sort buffer size” anymore.
This error cause by low config value in MySQL ini file or in MySQL custom ini setup and you set sort_buffer_size value too low. Sort_buffer_size control sort buffer when sorting a table. Normal, MySQL or MariaDB, sort_buffer_size value will be set by automatic or ignore and empty. So, when ther is no value for sort_buffer_size or sort_buffer_size value too low, it will show an error: “Out of sort memory, consider increasing sort buffer size” when you save a large data.
How to fix “Out of sort memory, consider increasing sort buffer size”:
If you control your own server, or VPS, it is very simple to fix it. And it’s not related to your code, it’s server side. Because this error cause by sort_buffer_size value is too low in MySQL Configuration (normal in this file: /etc/my.cnf ).
So, the easy way is just open MySQL config file and increase sort_buffer_size value. Normal, config file is set at /etc/my.cnf. If it is not there, you can find the MySQL config file by run this command in terminal:

That command will show a result something like this:

So, look at the result, we will know which file is MySQL configuration file. Then you can use vi, nano or any command which can edit file in terminal and open that file. Look up for this line:

You will saw a low value of sort_buffer_size. You can increase it by set another value for sort_buffer_size. You can double it, triple it or increase what ever you want. In our case, when i saw “Out of sort memory ” in my Joomla 3.8 size, i check sort_buffer_size  and i saw value is 128K. Then i try to increase it to  “sort_buffer_size = 512K”, after that, everything is Ok and errror message gone away.
Depend on your server, you can set sort_buffer_size value to any value bigger than default value.

sort_buffer_size = 128K mean 128 Kilobytes
sort_buffer_size = 128M mean 128 Megabytes
Number value 128 could be anything like 256, 512, 1024, 2048 …

Last update: 15:47:39 PM, 23rd May 2018
Share.

About Author

Leave A Reply