Search code examples
mysqlcharacter-encodingutf8mb4

High CPU on MySQL after running CONVERT_TO_CHARACTER_SET


After running the following command on a SQL database, the CPU usage has shot up to 100%. Queries can be taking upwards of 60 seconds. Here is the command:

ALTER TABLE database_splishuser CONVERT TO CHARACTER SET utf8mb4;

Does using the CONVERT TO CHARACTER SET command need further commands to ensure that the table is set up correctly after running it?


Solution

  • The problem was that we converted one of our tables to a new collation, but a column in that table was frequently used in comparisons with another column from another table in our database. Since we had not converted that table yet, the comparisons took an extremely long amount of time (and usually did not finish, putting lots of strain on the DB).

    Converting all the tables in our database to the same collation and character set solved the issue.