I have a serious performance issue about mysql.
The storage engine is myisam.
I find such pattern in slow log:
if the update command is slow, a use database_name will be in front of it, and the lock time will be long.
does use database_name command lock the whole database? will database_name command flush the cache and then has bad effects in update command?
No, the use database command does not have a great cost.
But the UPDATE statement locks the whole table if you use MyISAM. You’re probably seeing multiple UPDATE statements queuing up against each other.
I recommend using InnoDB for all tables. Not only for its support for row-level locking (actually MVCC which is better than row-level locking), but also InnoDB is superior to MyISAM in terms of resistance against data corruption.