笔记整理之 MySQL内存计算方式

 

-- 计算MySQL的内存峰值公式,计算所有的连接满了的情况下:

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

    )

)/1024/1024/1024;

 

执行命令:
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))/1024/1024/1024 as max_used_memory;


执行结果:
+------------------+
| max_used_memory  |
+------------------+
| 998.379882812500 |
+------------------+
1 row in set (0.00 sec)

 

-- 内存单个连接值计算 1

select @@read_buffer_size , @@read_rnd_buffer_size

        , @@sort_buffer_size, @@join_buffer_size

        , @@binlog_cache_size, @@thread_stack;       

 

-- 内存单个连接值计算 2

select @@key_buffer_size , @@query_cache_size , @@tmp_table_size

    , @@innodb_buffer_pool_size , @@innodb_additional_mem_pool_size

    , @@innodb_log_buffer_size;

你可能感兴趣的:(mysql)