MySQL - 将大型临时表与生产表同步
我有一个包含超过 400 万条记录的表。有一个临时表,可全天通过 ETL 流程更新数据。临时表更新后,我需要将该数据与生产表同步。我目前正在使用 INSERT/ON DUPLICATE KEY UPDATE 查询来同步它们,但是由于该表的大小,运行大约需要 750 秒。有没有更有效的方法来更新/插入新数据?我已经阅读了一些有关分区表的内容,但我不确定这是否是我需要做的。谁能给我一些关于如何更有效地完成此任务的建议?
I have a table with 4mil+ records. There is a staging table that gets updated with data via an ETL process throughout the day. Once the staging table gets updated, I need to then sync that data with the production table. I'm currently using an INSERT/ON DUPLICATE KEY UPDATE query to sync them, however with the size of this table it takes ~750 seconds to run. Is there a more efficient way to update/insert the new data? I have read some about partitioning tables, but I'm not sure if that's what I need to do or not. Can anyone give me some suggestions on how to do accomplish this more efficiently?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会使用 maatkit 工具(http://www.maatkit.org/),特别是 http://www.maatkit.org/doc/mk-table-sync.html。它在这类事情上非常有效。
I would use the maatkit tools (http://www.maatkit.org/), specifically http://www.maatkit.org/doc/mk-table-sync.html. It is pretty efficient at this sort of thing.