Are there any pitfalls / things you need to know when changing from MyISAM to InnoDB

后端 未结 6 1047
遇见更好的自我
遇见更好的自我 2021-02-01 11:02

One of my projects use the MyISAM engine in MySQL, but I\'m considering changing it to InnoDB as I need transaction support here and there.

  • What should I look at o
6条回答
  •  伪装坚强ぢ
    2021-02-01 11:25

    Some other notes:

    InnoDB does not reallocate free space on the filesystem after you drop a table/database or delete a record, this can be solved by "dumping and importing" or setting innodb_file_per_table=1 in my.cnf.

    Adding/removing indexes on a large InnoDB table can be quite painfull, because it locks the current table, creates a temporary one with your altered indexes and inserts data - row by row. There is a plugin from Innobase, but it works only for MySQL 5.1

    InnoDB is also MUCH MORE memory intense, I suggest you to have as large innodb_buffer_pool_size variable as your server memory allows (70-80% should be a safe bet). If your server is UNIX/Linux, consider reducing sysctl variable vm.swappiness to 0 and use innodb_flush_method=O_DIRECT to avoid double buffering. Always test if you hit swap when toggling those values.You can always read more at Percona blog, which is great.

    Also, you can run mysqlbackup with --single-transaction --skip-lock-tables and have no table locks while the backup is commencing.

    In any case, InnoDB is great, do not let some pitfalls discourage you.

提交回复
热议问题