MySQL内存占用计算

##MySQL 最大可使用内存( M ): 

SELECT 
  (
    @@key_buffer_size + @@innodb_buffer_pool_size + @@query_cache_size + @@tmp_table_size + @@max_connections * (
      @@read_buffer_size + @@read_rnd_buffer_size + @@sort_buffer_size + @@join_buffer_size + @@binlog_cache_size + @@thread_stack
    )
  ) / 1024 / 1024 AS result 
 
 ##MySQL 单个连接最大可使用内存( M ): 
  
  SELECT 
    (
      @@read_buffer_size + @@read_rnd_buffer_size + @@sort_buffer_size + @@join_buffer_size + @@binlog_cache_size + @@thread_stack
    ) / 1024 / 1024 AS result 

##MySQL 最大可使用内存(不包含连接占用内存)( M ): 

    SELECT 
      (
        @@key_buffer_size + @@innodb_buffer_pool_size + @@query_cache_size + @@tmp_table_size
      ) / 1024 / 1024 AS result 

  

posted @ 2018-10-31 10:23  MR__Wang  阅读(888)  评论(0编辑  收藏  举报