zoukankan      html  css  js  c++  java
  • MYSQL常用函数查询统计

    1.查看各参数内存配置方式
    #全局共享内存 9个变量
    show variables like 'innodb_buffer_pool_size'; /* InnoDB 数据和索引缓存(InnoDB Buffer Pool) */
    show variables like 'innodb_additional_mem_pool_size'; /* InnoDB 字典信息缓存(InnoDB Additional Memory Pool)*/
    show variables like 'innodb_log_buffer_size'; /* InnoDB 日志缓冲区(InnoDB Log Buffer) */
    show variables like 'binlog_cache_size'; /* 二进制日志缓冲区(Binlog Buffer)*/
    show variables like 'thread_cache_size'; /* 连接线程缓存(Thread Cache)*/
    show variables like 'query_cache_size'; /* 查询缓存(Query Cache)*/
    show variables like 'table_open_cache'; /* 表缓存(Table Cache) */
    show variables like 'table_definition_cache'; /* 表定义信息缓存(Table definition Cache) */
    show variables like 'key_buffer_size'; /* MyISAM索引缓存(Key Buffer) */
    #最大线程数
    show variables like 'max_connections';
    #线程独享内存 6个变量
    show variables like 'thread_stack'; /* 线线程栈信息使用内存(thread_stack) */
    show variables like 'sort_buffer_size'; /* 排序使用内存(sort_buffer_size) */
    show variables like 'join_buffer_size'; /* Join操作使用内存(join_buffer_size) */
    show variables like 'read_buffer_size'; /* 顺序读取数据缓冲区使用内存(read_buffer_size) */
    show variables like 'read_rnd_buffer_size'; /* 随机读取数据缓冲区使用内存(read_rnd_buffer_size) */
    show variables like 'tmp_table_size'; /* 临时表使用内存(tmp_table_size) ,我实际计算把tmp_table_size放入全局共享内*/
    也可以通过系统变量的方式直接获取
    select @@key_buffer_size;
    select @@max_connections


    2.mysql内存计算公式
    mysql使用的内存 = 全局共享内存+最大线程数×线程独享内存
    mysql used mem=innodb_buffer_pool_size+innodb_additional_mem_pool_size+innodb_log_buffer_size+binlog_cache_size+thread_cache_size+query_cache_size+table_open_cache+table_definition_cache+key_buffer_size
    +max_connections*(
    thread_stack+sort_buffer_size+join_buffer_size+read_buffer_size+read_rnd_buffer_size+tmp_table_size)

    SET @kilo_bytes=1024;
    SET @mega_bytes=@kilo_bytes*1024;
    SET @giga_bytes=@mega_bytes*1024;
    SELECT (@@innodb_buffer_pool_size+@@innodb_additional_mem_pool_size+@@innodb_log_buffer_size+@@binlog_cache_size+@@thread_cache_size+@@query_cache_size+@@table_open_cache+@@table_definition_cache+@@key_buffer_size+@@max_connections*(@@thread_stack+@@sort_buffer_size+@@join_buffer_size+@@read_buffer_size+@@read_rnd_buffer_size+@@tmp_table_size))/@giga_bytes AS MAX_MEMORY_GB;

    这个理论最大的内存使用量,在5.5版本中tmp_table_size默认是16M,按默认u自大连接数151计算,光线程独享的临时表占据的空间都是2416M,我实际计算把tmp_table_size放入全局共享内
    我的计算公式
    mysql使用的内存 = 全局共享内存+最大线程数×线程独享内存
    mysql used mem=innodb_buffer_pool_size+innodb_additional_mem_pool_size+innodb_log_buffer_size+binlog_cache_size+thread_cache_size+query_cache_size+table_open_cache+table_definition_cache+key_buffer_size+tmp_table_size
    +max_connections*(
    thread_stack+sort_buffer_size+join_buffer_size+read_buffer_size+read_rnd_buffer_size)

  • 相关阅读:
    背水一战 Windows 10 (90)
    背水一战 Windows 10 (89)
    背水一战 Windows 10 (88)
    背水一战 Windows 10 (87)
    背水一战 Windows 10 (86)
    背水一战 Windows 10 (85)
    背水一战 Windows 10 (84)
    背水一战 Windows 10 (83)
    背水一战 Windows 10 (82)
    背水一战 Windows 10 (81)
  • 原文地址:https://www.cnblogs.com/lhlucky/p/12788688.html
Copyright © 2011-2022 走看看