Archive

Posts Tagged ‘optimize’

MySQL table lock

April 25th, 2009 admin No comments

mysql> SHOW STATUS LIKE ‘Table%’;

+———————–+———+

| Variable_name         | Value   |

+———————–+———+

| Table_locks_immediate | 1151552 |

| Table_locks_waited    | 15324   |

+———————–+———+


mysql> LOCK TABLES real_table WRITE, insert_table WRITE;

mysql> INSERT INTO real_table SELECT * FROM insert_table;

mysql> TRUNCATE TABLE insert_table;

mysql> UNLOCK TABLES;

Note: “ insert_table” is a memory table, and after above operation, TRUNCATE this table, not delete *.

Categories: MySQL Tags: , ,