Mysql 更快的更新
我有 2 个 Innodb 表。在 TableA 中,我有一列 (guidNew),我想根据 TableA (guid) 和 TableB (所有者) 中的列之间的关系将其值分配给 TableB (所有者) 中的列。
基本上 Tabl6eB(所有者)有多个条目对应于一个 TableA(guid)。这是多对一的关系。我想将 TableB(owner) 值更改为新的 TableA(guidNew) 值。
这是一个查询示例:
UPDATE `TableB`, `TableA`
SET
`TableB`.`owner` = `TableA`.`guidNew`
WHERE `TableB`.`guid` != 0
AND `TableB`.`owner` = `TableA`.`guid`;
现在我不知道这是否有效,因为有超过 200 万条条目。有没有办法知道它的进展,更重要的是,有办法更快地完成它。
I have 2 Innodb tables. IN TableA I have a column (guidNew) that I want to assign its' values to a column in TableB (owner) depending on the relation between the column in TableA (guid) and TableB (owner).
Basically Tabl6eB (owner) has multiple entries that correspond to one TableA (guid). This is a Many to One relation. I want to change the TableB(owner) value to the new TableA(guidNew) values.
This is an example of the query:
UPDATE `TableB`, `TableA`
SET
`TableB`.`owner` = `TableA`.`guidNew`
WHERE `TableB`.`guid` != 0
AND `TableB`.`owner` = `TableA`.`guid`;
Now I do not know if this is working or not because there are more than 2 million entries. Is there a way to know the progress it has AND more important, a way to do it faster.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您已对 guid 和owner 列建立索引。
尝试使用
EXPLAIN
命令来查看查询是如何执行的Make sure that you have indexed the guid and owner columns.
Try using the
EXPLAIN
command to see how the query is being performed