|There are three main ways MySQL CPU usage becomes problematic ...
1 You have a table in memory that needs an index for what you are asking of it, so you're doing full table scans in memory. Fix that with a covering index.
3 Code in stored procedures, stored functions, stacked views. You'll need to re-jigger that approach.
More general issues to check ...
CPU usage spikes, or is continuously high?
What does top say? An i/o bottleneck will show higher cpu%; high mem usage will leave free mem low.
Check thread configuration starting with ...
show variables like '%threads%';
If global status var ratios ...
Select_range_check / Uptime_since_flush_status Select_scan / Uptime_since_flush_status... > 0, optimise those queries.
Suss out abusive processes and remove them.
Other useful links ...
Query CPU timeVersion 8.0.28 adds optional performance_schema tracking of CPU time spent on a query, see "Performance Schema Notes" at https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-28.html
Last updated 18 Jan 2022