Recently I had an interesting surprise with concurrent inserts
into a MyISAM table. The inserts were not happening concurrently
with SELECT statements; they were blocking and the process list
was filling up with queries in Locked status.
My first thought was that the customer had deleted from the
table, which leaves "holes" in the middle of it and prevents
concurrent inserts. (You can configure the server to permit
concurrent inserts even when there are holes, but it's disabled
by default.) However, that turned out not to be the cause; the
table was only inserted into (and selected from). Instead, the
blocked statements were because of INSERT... SELECT statements
that were running against the table, selecting data from it and
inserting into another table.
Let's look at what happens here: suppose you have two tables tbl1
and tbl2 and concurrent inserts into tbl2 are running fine. If
you now run the following query,
…
[Read more]