如何确定 MySQL 中的全局和线程缓冲区大小?

How to determine Global and Thread Buffer size in MySQL?

我目前正在调试与我的云sql mySQL 数据库相关的一些性能问题,并希望调查其配置参数。

在云 sql 文档中可以找到以下注释:

"Maximum concurrent connections - Note:

To determine the maximum value that you can set for this flag, the basic formulas are:

Available RAM = Global Buffers + (Thread Buffers x max_connections)

max_connections = (Available RAM - Global Buffers) / Thread Buffers

To get the list of buffers and their values: SHOW VARIABLES LIKE '%buffer%'; Allow some headroom for other processes requiring memory."

然而,运行 sql 命令产生以下输出:

mysql> SHOW VARIABLES LIKE '%buffer%';
+-------------------------------------+----------------+
| Variable_name                       | Value          |
+-------------------------------------+----------------+
| bulk_insert_buffer_size             | 8388608        |
| innodb_buffer_pool_chunk_size       | 55574528       |
| innodb_buffer_pool_dump_at_shutdown | ON             |
| innodb_buffer_pool_dump_now         | OFF            |
| innodb_buffer_pool_dump_pct         | 25             |
| innodb_buffer_pool_filename         | ib_buffer_pool |
| innodb_buffer_pool_in_core_file     | ON             |
| innodb_buffer_pool_instances        | 1              |
| innodb_buffer_pool_load_abort       | OFF            |
| innodb_buffer_pool_load_at_startup  | ON             |
| innodb_buffer_pool_load_now         | OFF            |
| innodb_buffer_pool_size             | 55574528       |
| innodb_change_buffer_max_size       | 25             |
| innodb_change_buffering             | all            |
| innodb_log_buffer_size              | 16777216       |
| innodb_sort_buffer_size             | 1048576        |
| join_buffer_size                    | 262144         |
| key_buffer_size                     | 8388608        |
| myisam_sort_buffer_size             | 8388608        |
| net_buffer_length                   | 16384          |
| preload_buffer_size                 | 32768          |
| read_buffer_size                    | 131072         |
| read_rnd_buffer_size                | 262144         |
| sort_buffer_size                    | 262144         |
| sql_buffer_result                   | OFF            |
+-------------------------------------+----------------+
25 rows in set (0.02 sec)

我不明白要将哪些值代入公式。哪些值对应于全局缓冲区和线程缓冲区?

我发现这个 blog article 列出了全局缓冲区和线程缓冲区变量,它们是:

  • 全局缓冲区:

    key_buffer_size
    innodb_buffer_pool_size
    innodb_log_buffer_size
    innodb_additional_mem_pool_size
    net_buffer_size
    query_cache_size
    
  • 线程缓冲区:

    sort_buffer_size
    myisam_sort_buffer_size
    read_buffer_size 
    join_buffer_size
    read_rnd_buffer_size
    thread_stack