开发者

Mysql Faster UPDATE

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`, `Tab开发者_开发知识库leA`
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.


Make sure that you have indexed the guid and owner columns.

Try using the EXPLAIN command to see how the query is being performed

EXPLAIN SELECT TableB.owner, TableA.guidNew
FROM TableB, TableA
WHERE TableB.guid != 0 
AND TableB.owner = TableA.guid
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜