mysql 記憶體計算 MySQL記憶體計算公式

2021-10-17 16:23:59 字數 2003 閱讀 8344

mysql記憶體計算公式mysql used mem = key_buffer_size + query_cache_size + tmp_table_size+ innodb_buffer_pool_size + innodb_additional_mem_pool_size+ innodb_log_buffer_size+

max_connections * (read_buffer_size + read_rnd_buffer_size+ sort_buffer_size+ join_buffer_size+ binlog_cache_size + thread_stack)

在mysql中輸入如下命令,可顯示各佔記憶體引數大小show variables like   'key_buffer_size';

show variables like   'query_cache_size';

show variables like   'tmp_table_size';

show variables like   'innodb_buffer_pool_size';

show variables like   'innodb_additional_mem_pool_size';

show variables like   'innodb_log_buffer_size';

show variables like   'read_buffer_size';

show variables like   'read_rnd_buffer_size';

show variables like   'sort_buffer_size';

show variables like   'join_buffer_size';

show variables like   'binlog_cache_size';

show variables like   'thread_stack';

在mysql中輸入如下命令,可自動計算自己的當前配置最大的記憶體消耗show variables like'innodb_buffer_pool_size';

show variables like 'innodb_additional_mem_pool_size';

show variables like 'innodb_log_buffer_size';

show variables like 'thread_stack';

set @kilo_bytes = 1024;

set @mega_bytes = @kilo_bytes * 1024;

set @giga_bytes = @mega_bytes * 1024;

set @innodb_buffer_pool_size = 2 * @giga_bytes;

set @innodb_additional_mem_pool_size = 16 * @mega_bytes;

set @innodb_log_buffer_size = 8 * @mega_bytes;

set @thread_stack = 192 * @kilo_bytes;

select ( @@key_buffer_size + @@query_cache_size + @@tmp_table_size + @innodb_buffer_pool_size + @innodb_additional_mem_pool_size + @innodb_log_buffer_size + @@max_connections * ( @@read_buffer_size + @@read_rnd_buffer_size + @@sort_buffer_size + @@join_buffer_size + @@binlog_cache_size + @thread_stack) ) / @giga_bytes as max_memory_gb;

也可以使用.sql指令碼執行,將上面命令儲存到mysql_mem.sql,儲存到/root/script下,進入mysql中使用source命令執行sql指令碼:mysql> source /root/script/mysql_mem.sql;

mysql 記憶體計算 MYSQL使用記憶體計算

mysql記憶體占用計算 global buffer all thread buffer global buffer innodb buffer pool size 快取表資料和索引資料,加速查詢,並且使查詢結果集儲存在內以供重用,一般設定到主機記憶體的70 以下 innodb additional...

mysql 記憶體計算 mysql 記憶體的計算方法

使用tuning primer 分析mysql 看了 後對記憶體的分配有了一些了解,分享一下 實際記憶體使用主要分為幾部分 1 全域性buffer global buffer 包括 innodb buffer pool size innodb additional mem pool size inn...

mysql初始記憶體計算 MYSQL使用記憶體計算

mysql記憶體占用計算 global buffer all thread buffer global buffer innodb buffer pool size 快取表資料和索引資料,加速查詢,並且使查詢結果集儲存在內以供重用,一般設定到主機記憶體的70 以下 innodb additional...