<tfoot id='zFCCN'></tfoot>
      <legend id='zFCCN'><style id='zFCCN'><dir id='zFCCN'><q id='zFCCN'></q></dir></style></legend>

        <bdo id='zFCCN'></bdo><ul id='zFCCN'></ul>

        <i id='zFCCN'><tr id='zFCCN'><dt id='zFCCN'><q id='zFCCN'><span id='zFCCN'><b id='zFCCN'><form id='zFCCN'><ins id='zFCCN'></ins><ul id='zFCCN'></ul><sub id='zFCCN'></sub></form><legend id='zFCCN'></legend><bdo id='zFCCN'><pre id='zFCCN'><center id='zFCCN'></center></pre></bdo></b><th id='zFCCN'></th></span></q></dt></tr></i><div id='zFCCN'><tfoot id='zFCCN'></tfoot><dl id='zFCCN'><fieldset id='zFCCN'></fieldset></dl></div>
      1. <small id='zFCCN'></small><noframes id='zFCCN'>

        如何查看 MySQL 内部 innodb 临时表的大小

        时间:2023-06-24

          • <i id='mhnTe'><tr id='mhnTe'><dt id='mhnTe'><q id='mhnTe'><span id='mhnTe'><b id='mhnTe'><form id='mhnTe'><ins id='mhnTe'></ins><ul id='mhnTe'></ul><sub id='mhnTe'></sub></form><legend id='mhnTe'></legend><bdo id='mhnTe'><pre id='mhnTe'><center id='mhnTe'></center></pre></bdo></b><th id='mhnTe'></th></span></q></dt></tr></i><div id='mhnTe'><tfoot id='mhnTe'></tfoot><dl id='mhnTe'><fieldset id='mhnTe'></fieldset></dl></div>
                <bdo id='mhnTe'></bdo><ul id='mhnTe'></ul>

                  <tbody id='mhnTe'></tbody>

                <small id='mhnTe'></small><noframes id='mhnTe'>

                <legend id='mhnTe'><style id='mhnTe'><dir id='mhnTe'><q id='mhnTe'></q></dir></style></legend>
                <tfoot id='mhnTe'></tfoot>

                1. 本文介绍了如何查看 MySQL 内部 innodb 临时表的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我看到了大量的内部正在写入临时磁盘表.我可以通过 SHOW GLOBAL STATUS where Variable_name like 'Created_tmp_disk_tables' 查看计数.

                  I'm seeing a large number of internal temporary disk tables being written. I can see the count with SHOW GLOBAL STATUS where Variable_name like 'Created_tmp_disk_tables'.

                  我知道我可以更新 max_heap_table_sizetmp_table_size 来帮助防止这种情况发生,但是如果不知道写入磁盘的表的大小,就很难知道要使用哪些值用.

                  I know I can update max_heap_table_size and tmp_table_size to help prevent this, but without knowing the size of the tables getting written to disk, it's difficult to know what values to use.

                  有人知道如何找到这个值吗?

                  Does anyone know how to go about finding this value?

                  推荐答案

                  这不容易得到.在 Percona Server 中,有一些选项可以在显示临时表大小的慢查询日志中添加其他信息(请参阅 https://www.percona.com/doc/percona-server/5.7/diagnostics/slow_extended.html)

                  This is not easy to get. In Percona Server, there are options to add additional information in the slow query log that shows the size of temp tables (see https://www.percona.com/doc/percona-server/5.7/diagnostics/slow_extended.html)

                  # User@Host: mailboxer[mailboxer] @  [192.168.10.165]
                  # Thread_id: 11167745  Schema: board
                  # Query_time: 1.009400  Lock_time: 0.000190  Rows_sent: 4  Rows_examined: 1543719  Rows_affected: 0  Rows_read: 4
                  # Bytes_sent: 278  Tmp_tables: 0  Tmp_disk_tables: 0  Tmp_table_sizes: 0
                  # QC_Hit: No  Full_scan: Yes  Full_join: No  Tmp_table: No  Tmp_table_on_disk: No
                  # Filesort: No  Filesort_on_disk: No  Merge_passes: 0
                  

                  (上面的示例取自 Percona 文档,显示了扩展字段,尽管示例是针对未创建临时表的查询,因此大小显示为 0.)

                  (The example above, taken from the Percona documentation, shows the extended fields, although the example is for a query that did not create temp tables, so the size is shown as 0.)

                  在 Oracle MySQL 中,某些相同的扩展信息在 PERFORMANCE_SCHEMA 中的查询事件中可用 - 但不是临时表大小.

                  In Oracle MySQL, some of the same extended information is available in query events in the PERFORMANCE_SCHEMA—but not the temp table sizes.

                  在 2014 年,我记录了一个功能请求以提供此信息:https://bugs.mysql.com/bug.php?id=74484 并且此错误已被确认,但据我所知尚未实现.

                  In 2014, I logged a feature request to supply this information: https://bugs.mysql.com/bug.php?id=74484 and this bug has been acknowledged, but this has not been implemented as far as I know.

                  有点不清楚这将如何实现,因为任何给定的查询都可能创建多个不同大小的临时表.我相信 Percona 功能会在这种情况下显示临时表大小的总和.

                  It's a little bit unclear how this would be implemented, since it's possible for any given query to create multiple temp tables of different sizes. I believe the Percona feature shows the sum total of the temp table sizes in such cases.

                  我只能提供一个建议,以增量方式增加 max_heap_table_sizetmp_table_size,并监控 Created_tmp_disk_tables 的增加率由 SHOW GLOBAL STATUS 报告,与 Created_tmp_tables(不使用磁盘的临时表)相比.由于允许的 tmp 表大小能够容纳更多创建的临时表,您应该开始看到磁盘临时表与内存中临时表的比率下降.

                  All I can offer as a suggestion is to increase the max_heap_table_size and tmp_table_size in increments, and monitor the rate of increase of the Created_tmp_disk_tables reported by SHOW GLOBAL STATUS, compared to Created_tmp_tables (temp tables that did not use disk). As the allowed tmp table size is able to hold a greater percentage of temp tables created, you should start to see the ratio of on-disk temp tables to in-memory temp tables decrease.

                  通常没有必要增加tmp_table_size 来容纳每个 可能的临时表,无论有多大.您希望最大的异常值使用磁盘.但是只要临时表 98% 的时间都使用内存,你应该没问题.这意味着 Created_tmp_disk_tables 与 Created_tmp_tables 的比率应该是 1:50 或更多.

                  It's typically not necessary to increase tmp_table_size to hold every possible temp table, no matter how large. You want the largest outliers to use the disk. But as long as the temp tables use memory 98% of the time, you should be fine. That would mean that the ratio of Created_tmp_disk_tables to Created_tmp_tables should be 1:50 or more.

                  这篇关于如何查看 MySQL 内部 innodb 临时表的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:除非指定了主键,否则防止从表中删除 * 下一篇:将 MySQL 8.0.20 数据库迁移到 AWS Aurora

                  相关文章

                    <bdo id='29a8e'></bdo><ul id='29a8e'></ul>
                2. <legend id='29a8e'><style id='29a8e'><dir id='29a8e'><q id='29a8e'></q></dir></style></legend>

                3. <i id='29a8e'><tr id='29a8e'><dt id='29a8e'><q id='29a8e'><span id='29a8e'><b id='29a8e'><form id='29a8e'><ins id='29a8e'></ins><ul id='29a8e'></ul><sub id='29a8e'></sub></form><legend id='29a8e'></legend><bdo id='29a8e'><pre id='29a8e'><center id='29a8e'></center></pre></bdo></b><th id='29a8e'></th></span></q></dt></tr></i><div id='29a8e'><tfoot id='29a8e'></tfoot><dl id='29a8e'><fieldset id='29a8e'></fieldset></dl></div>

                      <tfoot id='29a8e'></tfoot>

                    1. <small id='29a8e'></small><noframes id='29a8e'>