# Setting the values for read\_buffer\_size, sort\_buffer\_size

**URL:** <https://forums.percona.com/t/setting-the-values-for-read-buffer-size-sort-buffer-size/496>\
**Category:** Other MySQL® Questions\
**Created:** [October 20, 2007, 12:06pm UTC](https://forums.percona.com/t/setting-the-values-for-read-buffer-size-sort-buffer-size/496 "2007-10-20T12:06:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![catalin](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@catalin](https://forums.percona.com/u/catalin)\
**Post date:** [October 20, 2007, 12:06pm UTC](https://forums.percona.com/t/setting-the-values-for-read-buffer-size-sort-buffer-size/496/1 "2007-10-20T12:06:44Z")

</div>

Hello,

I know that the most important formula to respect when tunning a MySQL server is:

key\_buffer\_size + (read\_buffer\_size + sort\_buffer\_size)\*max\_connections = total\_memory

I know total\_memory and that key\_buffer\_size should be 30%-40% of the total\_memory

But how about read\_buffer\_size, sort\_buffer\_size and max\_connections, how do I actually know what size to set them. Is there a diagnostic tool that can tell me the peaks, medium, etc values that my server is actually using for each of them? Or where to start, what parameters to take into consideration when determining the sizes of these variables

And what are the definitions for read\_buffer\_size, sort\_buffer\_size. ( What do these variables represent ? )

This is my current configuration for a 8G of RAM server and I keep running out of RAM and I have no idea where the problem is

set-variable = max\_connections=3096  
set-variable = max\_allowed\_packet=15M  
key\_buffer\_size = 1024M  
table\_cache = 1024  
sort\_buffer\_size = 8M  
read\_buffer\_size = 8M  
read\_rnd\_buffer\_size = 16M  
myisam\_sort\_buffer\_size = 3M  
thread\_cache = 32  
thread\_concurrency = 16  
open-files-limit= 261424  
set-variable = thread\_stack=512k  
set-variable = query\_cache\_size=128M  
set-variable = wait\_timeout=120  
set-variable = interactive\_timeout=60  
set-variable = max\_connect\_errors=999999

thanks

---

<div class="post-metadata">

**Author:** ![xxclixxx](https://avatars.discourse-cdn.com/v4/letter/x/67e7ee/32.png) [@xxclixxx](https://forums.percona.com/u/xxclixxx)\
**Post date:** [October 22, 2007, 1:17pm UTC](https://forums.percona.com/t/setting-the-values-for-read-buffer-size-sort-buffer-size/496/2 "2007-10-22T13:17:52Z")

</div>

Hi

I use this tool:  
[URL][http://rackerhacker.com/mysqltuner/[/URL]](http://rackerhacker.com/mysqltuner/%5B/URL%5D)

It will give you suggestions based on the mysql stats variables. I know very little about MySQL so I take those suggestions and search for the variables and then read what people are saying about them. That way you know if those changes will help in your situation.

As for always using up RAM. I wasn’t aware of this till recently, but apparently linux will use all the ram it can for caching. If you type “free -m” in SSH, it’ll show you the buffers/cache usage. This can be used by apps and such, so it isn’t like 100% used. But I suppose if it found a use for it, it wouldn’t hurt to let it keep using it =P
