Miguel and Domas, With the Performance Schema monitoring in mysql-6.0-perf we're able to look at this without needing a debugger or OS-dependent tool. We find that the number of mutex invocations varies between 2 and 10 depending on the INSERT. It's always happening in charset.c:529. If we change to engine=MyISAM, it stops happening after the first INSERT. It would be great if you'd check our results. Using Performance Schema for bug analysis is fairly new, but it will become fairly common if all goes well. Method: Download and build mysql-6.0-perf and start mysqld. (Marc has checked; the code is apparently the same in 5.1 and in 6.0.) Do this on a client: USE test DELIMITER // UPDATE performance_schema.setup_instruments SET enabled = CASE WHEN name LIKE '%THR_LOCK_charset' THEN 'YES' ELSE 'NO' END// DROP TABLE IF EXISTS tb// DROP PROCEDURE IF EXISTS p// CREATE TABLE `tb` ( `col1` varchar(200) DEFAULT NULL, KEY `col1` (`col1`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8// CREATE PROCEDURE p () BEGIN DECLARE iteration_number INT DEFAULT 1; DECLARE last_timer_start BIGINT; WHILE iteration_number <= 30 DO SET last_timer_start = (SELECT MAX(timer_end) FROM performance_schema.events_waits_current); INSERT INTO tb VALUES (REPEAT('a',200)); SELECT iteration_number, event_id, source, timer_wait FROM performance_schema.events_waits_history WHERE timer_start > last_timer_start; SET iteration_number = iteration_number + 1; END WHILE; END// CALL p()// Explanation: the above code disables every instrument except the one associated with THR_LOCK_charset, then creates a procedure which says INSERT thirty times. Each time, it displays which iteration it's on, and the events which have happened since the last INSERT. The following is a sample run taken today with SUSE 10 x86-32. The results should be repeatable on other machines but of course the values in the TIMER_WAIT column (which is in "picoseconds") will vary. The rest of this comment is a sample run. linux:/usr/local/mysql/var # /usr/local/mysql/bin/mysql --user=root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 6.0.10-alpha-perfschema Source distribution Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> USE test Database changed mysql> DELIMITER // mysql> UPDATE performance_schema.setup_instruments -> SET enabled = CASE WHEN name LIKE '%THR_LOCK_charset' THEN 'YES' ELSE 'NO' END// Query OK, 238 rows affected (0.00 sec) Rows matched: 239 Changed: 238 Warnings: 0 mysql> DROP TABLE IF EXISTS tb// Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> DROP PROCEDURE IF EXISTS p// Query OK, 0 rows affected, 1 warning (0.01 sec) mysql> CREATE TABLE `tb` ( -> `col1` varchar(200) DEFAULT NULL, -> KEY `col1` (`col1`) -> ) ENGINE=InnoDB DEFAULT CHARSET=utf8// Query OK, 0 rows affected, 1 warning (0.09 sec) mysql> CREATE PROCEDURE p () -> BEGIN -> DECLARE iteration_number INT DEFAULT 1; -> DECLARE last_timer_start BIGINT; -> WHILE iteration_number <= 30 DO -> SET last_timer_start = (SELECT MAX(timer_end) FROM performance_schema.events_waits_current); -> INSERT INTO tb VALUES (REPEAT('a',200)); -> SELECT iteration_number, event_id, source, timer_wait -> FROM performance_schema.events_waits_history -> WHERE timer_start > last_timer_start; -> SET iteration_number = iteration_number + 1; -> END WHILE; -> END// Query OK, 0 rows affected (0.00 sec) mysql> CALL p()// +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 1 | 131 | charset.c:529 | 44446 | | 1 | 132 | charset.c:529 | 44446 | | 1 | 133 | charset.c:529 | 44446 | | 1 | 134 | charset.c:529 | 44446 | | 1 | 135 | charset.c:529 | 44446 | | 1 | 136 | charset.c:529 | 44446 | | 1 | 137 | charset.c:529 | 44446 | | 1 | 138 | charset.c:529 | 44446 | | 1 | 139 | charset.c:529 | 44446 | | 1 | 140 | charset.c:529 | 44446 | +------------------+----------+---------------+------------+ 10 rows in set (0.00 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 2 | 141 | charset.c:529 | 209084 | | 2 | 142 | charset.c:529 | 74494 | +------------------+----------+---------------+------------+ 2 rows in set (0.02 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 3 | 143 | charset.c:529 | 826946 | | 3 | 144 | charset.c:529 | 68234 | | 3 | 145 | charset.c:529 | 55088 | +------------------+----------+---------------+------------+ 3 rows in set (0.03 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 4 | 146 | charset.c:529 | 293594 | | 4 | 147 | charset.c:529 | 68234 | | 4 | 148 | charset.c:529 | 55088 | | 4 | 149 | charset.c:529 | 58218 | +------------------+----------+---------------+------------+ 4 rows in set (0.05 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 5 | 151 | charset.c:529 | 75746 | | 5 | 152 | charset.c:529 | 55088 | | 5 | 153 | charset.c:529 | 55088 | | 5 | 154 | charset.c:529 | 55088 | | 5 | 150 | charset.c:529 | 632886 | +------------------+----------+---------------+------------+ 5 rows in set (0.06 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 6 | 155 | charset.c:529 | 267302 | | 6 | 156 | charset.c:529 | 85762 | +------------------+----------+---------------+------------+ 2 rows in set (0.08 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 7 | 157 | charset.c:529 | 639146 | | 7 | 158 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.09 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 8 | 159 | charset.c:529 | 223482 | | 8 | 160 | charset.c:529 | 83258 | +------------------+----------+---------------+------------+ 2 rows in set (0.11 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 9 | 161 | charset.c:529 | 701746 | | 9 | 162 | charset.c:529 | 74494 | +------------------+----------+---------------+------------+ 2 rows in set (0.12 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 10 | 163 | charset.c:529 | 283578 | | 10 | 164 | charset.c:529 | 85762 | +------------------+----------+---------------+------------+ 2 rows in set (0.14 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 11 | 165 | charset.c:529 | 595326 | | 11 | 166 | charset.c:529 | 70738 | +------------------+----------+---------------+------------+ 2 rows in set (0.15 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 12 | 167 | charset.c:529 | 607846 | | 12 | 168 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.16 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 13 | 169 | charset.c:529 | 262294 | | 13 | 170 | charset.c:529 | 85136 | +------------------+----------+---------------+------------+ 2 rows in set (0.18 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 14 | 171 | charset.c:529 | 551506 | | 14 | 172 | charset.c:529 | 74494 | +------------------+----------+---------------+------------+ 2 rows in set (0.19 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 15 | 173 | charset.c:529 | 443208 | | 15 | 174 | charset.c:529 | 86388 | +------------------+----------+---------------+------------+ 2 rows in set (0.20 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 16 | 175 | charset.c:529 | 639146 | | 16 | 176 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.22 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 17 | 177 | charset.c:529 | 405022 | | 17 | 178 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.23 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 18 | 179 | charset.c:529 | 526466 | | 18 | 180 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.25 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 19 | 321 | charset.c:529 | 55088 | | 19 | 322 | charset.c:529 | 55088 | | 19 | 323 | charset.c:529 | 55088 | | 19 | 324 | charset.c:529 | 55088 | | 19 | 325 | charset.c:529 | 55088 | | 19 | 326 | charset.c:529 | 55088 | | 19 | 317 | charset.c:529 | 55088 | | 19 | 318 | charset.c:529 | 55088 | | 19 | 319 | charset.c:529 | 55088 | | 19 | 320 | charset.c:529 | 55088 | +------------------+----------+---------------+------------+ 10 rows in set (0.26 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 20 | 327 | charset.c:529 | 411282 | | 20 | 328 | charset.c:529 | 83258 | +------------------+----------+---------------+------------+ 2 rows in set (0.28 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 21 | 329 | charset.c:529 | 614106 | | 21 | 330 | charset.c:529 | 74494 | +------------------+----------+---------------+------------+ 2 rows in set (0.29 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 22 | 331 | charset.c:529 | 339292 | | 22 | 332 | charset.c:529 | 84510 | +------------------+----------+---------------+------------+ 2 rows in set (0.31 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 23 | 333 | charset.c:529 | 589066 | | 23 | 334 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.32 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 24 | 335 | charset.c:529 | 197190 | | 24 | 336 | charset.c:529 | 83258 | +------------------+----------+---------------+------------+ 2 rows in set (0.34 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 25 | 337 | charset.c:529 | 833206 | | 25 | 338 | charset.c:529 | 72616 | +------------------+----------+---------------+------------+ 2 rows in set (0.35 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 26 | 339 | charset.c:529 | 632886 | | 26 | 340 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.36 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 27 | 341 | charset.c:529 | 313626 | | 27 | 342 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.38 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 28 | 343 | charset.c:529 | 589066 | | 28 | 344 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.39 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 29 | 345 | charset.c:529 | 310496 | | 29 | 346 | charset.c:529 | 85762 | +------------------+----------+---------------+------------+ 2 rows in set (0.40 sec) +------------------+----------+---------------+------------+ | iteration_number | event_id | source | timer_wait | +------------------+----------+---------------+------------+ | 30 | 347 | charset.c:529 | 789386 | | 30 | 348 | charset.c:529 | 68234 | +------------------+----------+---------------+------------+ 2 rows in set (0.42 sec) Query OK, 0 rows affected (0.42 sec)