Question

We have a MyISAM table with about 20GB of data, with FULLTEXT index. We have several triggers which manipulate that table, which get called about 10 times per second. Now we want to run OPTIMIZE TABLE to rebuild the index. AFAIK OPTIMIZE TABLE locks the table for writes. So what happens to the queries created by the triggers, if OPTIMIZE TABLE takes about 6 hours? Is it a problem? Will queries get dropped after some time? Or what else can we do to rebuild the index?

Was it helpful?

Solution

While the table is locked, no writes can occur to the table. Any triggers attempting to write will hang until they get a lock-wait timeout.

You can use pt-online-schema-change to do a table restructure without blocking access to the original table.

Otherwise, configure a pair of servers in master-master replication, do the optimize table on the second master, then swap their roles and do the optimize table on the first master.

OTHER TIPS

There are more and better options. (1) Set "concurrent_insert = 1" for MyISAM. (2) Use InnoDB, which has optimized fulltext search indexing. This summary based on what I have read here..

https://dba.stackexchange.com/questions/36666/bypass-myisam-table-lock

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top