• <tfoot id='xuWGy'></tfoot>

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

      1. <legend id='xuWGy'><style id='xuWGy'><dir id='xuWGy'><q id='xuWGy'></q></dir></style></legend>

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

      2. MySQL的alter table查询速度很慢

        MySQL very slow for alter table query(MySQL的alter table查询速度很慢)
        <i id='nxjvQ'><tr id='nxjvQ'><dt id='nxjvQ'><q id='nxjvQ'><span id='nxjvQ'><b id='nxjvQ'><form id='nxjvQ'><ins id='nxjvQ'></ins><ul id='nxjvQ'></ul><sub id='nxjvQ'></sub></form><legend id='nxjvQ'></legend><bdo id='nxjvQ'><pre id='nxjvQ'><center id='nxjvQ'></center></pre></bdo></b><th id='nxjvQ'></th></span></q></dt></tr></i><div id='nxjvQ'><tfoot id='nxjvQ'></tfoot><dl id='nxjvQ'><fieldset id='nxjvQ'></fieldset></dl></div>
        • <bdo id='nxjvQ'></bdo><ul id='nxjvQ'></ul>

                <tbody id='nxjvQ'></tbody>
            1. <legend id='nxjvQ'><style id='nxjvQ'><dir id='nxjvQ'><q id='nxjvQ'></q></dir></style></legend><tfoot id='nxjvQ'></tfoot>

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

                  本文介绍了MySQL的alter table查询速度很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  为什么简单地更新这个表添加一列需要一个多小时?该表有 1500 万行.它有 2 个索引和一个单键主键.ALTER TABLE 查询现在已处于复制到 tmp 表"状态 1 小时 15 分钟.

                  Why is it taking more than an hour to simply update this table to add a column? This table has 15M rows. It has 2 indexes and a single key primary key. The ALTER TABLE query has been in "copy to tmp table" state for 1 hour 15 minutes now.

                  ALTER TABLE `frugg`.`item_catalog_map` 
                  ADD COLUMN `conversion_url` TEXT NULL DEFAULT NULL
                  

                  表格:

                  mysql> describe item_catalog_map;
                  +------------------------+---------------+------+-----+---------+-------+
                  | Field                  | Type          | Null | Key | Default | Extra |
                  +------------------------+---------------+------+-----+---------+-------+
                  | catalog_unique_item_id | varchar(255)  | NO   | PRI | NULL    |       |
                  | catalog_id             | int(11)       | YES  | MUL | NULL    |       |
                  | item_id                | int(11)       | YES  | MUL | NULL    |       |
                  | price                  | decimal(10,2) | YES  |     | 0.00    |       |
                  +------------------------+---------------+------+-----+---------+-------+
                  
                  mysql> show index from item_catalog_map;
                  +------------------+------------+----------------------+--------------+------------------------+-----------+-------------+----------+--------+------+------------+---------+
                  | Table            | Non_unique | Key_name             | Seq_in_index | Column_name            | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
                  +------------------+------------+----------------------+--------------+------------------------+-----------+-------------+----------+--------+------+------------+---------+
                  | item_catalog_map |          0 | PRIMARY              |            1 | catalog_unique_item_id | A         |    15485115 |     NULL | NULL   |      | BTREE      |         |
                  | item_catalog_map |          1 | IDX_ACD6184FCC3C66FC |            1 | catalog_id             | A         |          18 |     NULL | NULL   | YES  | BTREE      |         |
                  | item_catalog_map |          1 | IDX_ACD6184F126F525E |            1 | item_id                | A         |    15485115 |     NULL | NULL   | YES  | BTREE      |         |
                  +------------------+------------+----------------------+--------------+------------------------+-----------+-------------+----------+--------+------+------------+---------+
                  

                  推荐答案

                  MySQL 的 ALTER TABLE 性能可能成为非常大的表的问题.MySQL 执行大多数更改是通过创建一个具有所需新结构的空表,将旧表中的所有数据插入到新表中,然后删除旧表.这可能需要很长时间,尤其是当您的内存不足并且表很大并且有很多索引时.许多人都曾经历过需要数小时或数天才能完成的 ALTER TABLE 操作.

                  MySQL’s ALTER TABLE performance can become a problem with very large tables. MySQL performs most alterations by making an empty table with the desired new structure, inserting all the data from the old table into the new one, and deleting the old table. This can take a very long time, especially if you’re short on memory and the table is large and has lots of indexes. Many people have experience with ALTER TABLE operations that have taken hours or days to complete.

                  无论如何,如果您需要继续使用 alter table,也许以下资源可以帮助您:

                  Anyway if you need to proceed with alter table, maybe the following resources could help you:

                  • https://www.percona.com/doc/percona-toolkit/2.2/pt-online-schema-change.html
                  • https://github.com/soundcloud/lhm
                  • https://githubengineering.com/gh-ost-github-s-online-migration-tool-for-mysql/

                  这篇关于MySQL的alter table查询速度很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                  SQL query to group by day(按天分组的 SQL 查询)
                  What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                  MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                  MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                  Include missing months in Group By query(在 Group By 查询中包含缺失的月份)
                  <legend id='U5snX'><style id='U5snX'><dir id='U5snX'><q id='U5snX'></q></dir></style></legend>

                  1. <tfoot id='U5snX'></tfoot>

                        • <bdo id='U5snX'></bdo><ul id='U5snX'></ul>

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

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

                              <tbody id='U5snX'></tbody>