HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Is it possible to determine MySQL pre-allocated memory footprint?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
prepossiblemysqldeterminememoryallocatedfootprint

Problem

At startup, MySQL will use some memory.

Some of the memory is pre-allocated for "key_buffer" and "innodb_buffer_pool_size" (and other things).

Is it possible to determine how much memory is pre-allocated (for data) and how much memory has been used?

Let me take an example to explain what I want to ask:

After I start MySQL server, it uses some memory as part of "key buffer". Say, I set key_buffer=1G. Maybe at startup, MySQL server has pre-allocated 200M as "key buffer". Then when users begin to do queries against this server. The server can only get extra 800M as "key buffer".

200 is a random number I pick. And apparently besides key_buffer, there are other things (such as innnodb buffer).

What I want to know is the exact size or the way to calculate it.

Solution

Yes, and you absolutely should! Don't set MySQL to have a potential maximum use more than about 80% of available memory.

MySQL has two types of buffers, global and per-connection. Maximum possible memory use is: global buffers + (connection buffers * max connections).

The mysqltuner.pl script will calculate this for you (http://mysqltuner.com/). Here are the values this script uses for calculating:

Global buffers:

key_buffer_size
max_tmp_table_size
innodb_buffer_pool_size
innodb_additional_mem_pool_size
innodb_log_buffer_size
query_cache_size


Per-connection buffers:

read_buffer_size
read_rnd_buffer_size
sort_buffer_size
thread_stack
join_buffer_size


You can find how much memory is currently used from your Operating System.

Code Snippets

key_buffer_size
max_tmp_table_size
innodb_buffer_pool_size
innodb_additional_mem_pool_size
innodb_log_buffer_size
query_cache_size
read_buffer_size
read_rnd_buffer_size
sort_buffer_size
thread_stack
join_buffer_size

Context

StackExchange Database Administrators Q#30991, answer score: 6

Revisions (0)

No revisions yet.