Mysql database table locks causes and solutions

Excerpt: https://www.csdn.net/gather_2f/MtTaIgxsMTM5NC1ibG9n.html

The reason the lock table:
When multiple connections (database connections) while a table of data update operation, then the speed will be slower and slower, the data table is locked phenomenon occurs after a sustained period of time, thus affecting the other inquiries and updates.  
For example:
a storage procedure 30 cycles of update operations (cycore_file_id unique identifier)

/*30次更新操作*/ 
BEGIN DECLARE v1 INT DEFAULT 30; WHILE v1 > 0 DO update jx_attach set complete=1,attach_size=63100 where cycore_file_id='56677142da502cd8907eb58f'; SET v1 = v1 - 1; END WHILE; END

 

The results (very slow)

Time: 29.876s

Procedure executed successfully
affected row: 0

 

200 data update operation, while performing a database connection three

update jx_attach set complete=1,attach_size=63100 where cycore_file_id='56677142da502cd8907eb58f';
 update jx_attach set complete=1,attach_size=63100 where cycore_file_id='56677142da502cd8907eb58f';
 update jx_attach set complete=1,attach_size=63100 where cycore_file_id='56677142da502cd8907eb58f';
 update jx_attach set complete=1,attach_size=63100 where cycore_file_id='56677142da502cd8907eb58f';
 update jx_attach set complete=1,attach_size=63100 where cycore_file_id='56677142da502cd8907eb58f';
 update jx_attach set complete=1,attach_size=63100 where cycore_file_id='56677142da502cd8907eb58f';
...等等

The results (after a period of time more slowly, there waiting for the lock)

# Time: 151208 22:41:24

  

  

 

Guess you like

Origin www.cnblogs.com/xinruyi/p/11108795.html