Free To Feel

Heading to entrepreneur.

Joshua Chi

Same update query only update once

Just learned more about the mysql update statement. I am very curious with this query:

UPDATE `table_name` SET `column3` = (`column1` | (`column2` * 2) ;

The first time, there are 10,000 items were updated. When I execute it again, 0 affected.

So there is no where condition, how can this happen? Learn it from mysql doc: Speed of UPDATE Statements.

Yes, it is because of the index.

  ...The speed of the write depends on the amount of data being updated and the number of indexes that are updated. Indexes that are not changed do not get updated. 
comments powered by Disqus