8.2.5.2 Optimizing UPDATE Statements优化更新语句

An update statement is optimized like a SELECT query with the additional overhead of a write. UPDATE语句像SELECT查询一样进行了优化,并增加了写入开销。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.未更改的索引不会得到更新。

Another way to get fast updates is to delay updates and then do many updates in a row later. 另一种获得快速更新的方法是延迟更新,然后在以后的一行中进行多次更新。Performing multiple updates together is much quicker than doing one at a time if you lock the table.如果锁定表,则同时执行多个更新要比一次执行一个更新快得多。

For a MyISAM table that uses dynamic row format, updating a row to a longer total length may split the row. 对于使用动态行格式的MyISAM表,将行更新为更长的总长度可能会拆分该行。If you do this often, it is very important to use OPTIMIZE TABLE occasionally. 如果您经常这样做,偶尔使用OPTIMIZE TABLE是非常重要的。See Section 13.7.3.4, “OPTIMIZE TABLE Statement”.请参阅第13.7.3.4节,“优化表格说明”