After testing on my instance, I saw occasional 1–3 second Lock_time on simple single-row queries against TOPIC_VIEWS (e.g., SELECT … WHERE p.POST_ID = ? AND p.TOPIC_ID = t.TOPIC_ID), even though Rows_examined is always 1.
The cause is concurrent INSERTs into {table_prefix}TOPIC_VIEWS (in showflat.inc.php) when multiple users view the same thread simultaneously—each insert queues row-level locks.
A low-contention fix is to keep using the existing {table_prefix}TOPIC_VIEWS table but convert it to InnoDB and switch to INSERT … ON DUPLICATE KEY UPDATE.
Steps:
Convert engine (run once)
ALTER TABLE {table_prefix}TOPIC_VIEWS ENGINE=InnoDB;Ensure TOPIC_ID is PRIMARY KEY
ALTER TABLE {table_prefix}TOPIC_VIEWS ADD PRIMARY KEY (TOPIC_ID);Replace the INSERT block in showflat.inc.php with:
if ($_SESSION['current_topic'] != $topic_info['TOPIC_ID']) {
$query = "
INSERT INTO {$config['TABLE_PREFIX']}TOPIC_VIEWS (TOPIC_ID)
VALUES (?)
ON DUPLICATE KEY UPDATE TOPIC_VIEWS = TOPIC_VIEWS + 1
";
$dbh->do_placeholder_query($query, array($topic_info['TOPIC_ID']), __LINE__, __FILE__);
$_SESSION['current_topic'] = $topic_info['TOPIC_ID'];
}This uses InnoDB row-level locking + upsert to eliminate queueing while keeping view counts accurate. I tested a variant and Lock_time dropped to zero.
Happy to provide more detail or diffs if useful—just a performance tweak suggestion.
Thanks!