Mysql changing table engine MyISAM to InnoDB

前端 未结 2 804
逝去的感伤
逝去的感伤 2020-12-16 17:03

On my site I have a visitor\'s table with 10 million rows.
Every request to the site inserts row to the table, in case the table is locked (usually in optimize query) v

相关标签:
2条回答
  • 2020-12-16 17:19

    oleksii.svarychevskyi is right, InnoDB uses row level locks, but if you do

    ALTER TABLE table_name ENGINE = InnoDB;
    to change table_name from MyIsam to InnoDB, there will be a metadata locking (at table level) because the original table engine was MyIsam.
    If you try to do an UPDATE over table_name, this UPDATE will be enqueued until the ALTER TABLE ends (if you do a SHOW FULL PROCESSLIST you will see a "Waiting for table metadata lock" message associated to the UPDATE).

    0 讨论(0)
  • 2020-12-16 17:30

    The easiest way is

    ALTER TABLE table_name ENGINE = InnoDB;
    

    If you use InnoDB engine you should not worry about locking tables, because this engine locks data by rows.

    0 讨论(0)
提交回复
热议问题