将表从 MyISAM 更改为 InnoDB 会使系统变慢
您好,我正在使用 Mysql 5.0.x,
我刚刚将很多表从 MyISAM 更改为 InnoDB
使用 MyISAM 表,大约需要1 分钟来安装我们的数据库 使用 InnoDB,安装相同的数据库大约需要15 分钟
为什么 InnoDB 需要这么长时间?
我能做些什么来加快速度? >
数据库安装执行以下步骤
1) 删除架构
2) 创建架构
3) 创建表
4) 创建存储过程
5) 插入默认数据
6) 通过存储过程插入数据
编辑:
插入默认数据占用了大部分时间时间
Hi I am using Mysql 5.0.x
I have just changed a lot of the tables from MyISAM to InnoDB
With the MyISAM tables it took about 1 minute to install our database
With the InnoDB it takes about 15 minute to install the same database
Why does the InnoDB take so long?
What can I do to speed things up?
The Database install does the following steps
1) Drops the schema
2) Create the schema
3) Create tables
4) Create stored procedures
5) Insert default data
6) Insert data via stored procedure
EDIT:
The Inserting of default data takes most of the time
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
修改插入数据步骤以在开始时启动事务并在结束时提交它。 你会得到进步,我保证。 (如果您有大量数据,您可能希望将事务分解为每个表。)
如果您的应用程序根本不使用事务,那么您应该将参数
innodb_flush_log_at_trx_commit
设置为 2。将为您带来大量性能恢复,因为您几乎肯定会启用 auto_commit,并且这会生成比 InnoDB 配置的默认参数多得多的事务。 此设置会阻止它在每次提交时不必要地刷新磁盘缓冲区。Modify the Insert Data step to start a transaction at the start and to commit it at the end. You will get an improvement, I guarantee it. (If you have a lot of data, you might want to break the transaction up to per table.)
If you application does not use transactions at all, then you should set the paramater
innodb_flush_log_at_trx_commit
to 2. This will give you a lot of performance back because you will almost certainly have auto_commit enabled and this generates a lot more transactions than InnoDB's default parameters are configured for. This setting stops it unnecessarily flushing the disk buffers on every commit.15分钟对我来说似乎并不过分。 毕竟,这是一次性成本。
我不确定,但我想部分解释是引用完整性不是免费的。 InnoDB需要做更多的工作来保证,所以当然会占用更多的时间。
也许您的脚本需要更改以在创建表后添加约束。
15 minutes doesn't seem excessive to me. After all, it's a one-time cost.
I'm not certain, but I would imagine that part of the explanation is the referential integrity isn't free. InnoDB has to do more work to guarantee it, so of course it would take up more time.
Maybe your script needs to be altered to add constraints after the tables are created.
就像达菲莫所说,在插入数据之前禁用约束(索引和外键/主键)。
如果使用大量 select 语句,也许您应该在通过存储过程插入数据之前恢复一些索引
Like duffymo said, disable your constraints(indexes and foreing/primary keys) before inserting the data.
Maybe you should restore some indexes before the data inserted via stored procedure, if its use a lot of select statements