I have a MySQL server with multiple websites running on it. These sites are mostly the same software, but since recently MySQL is under very high CPU load.
I'm pretty sure there is 1 MySQL user that is causing the higher load, but how can I identify the resources used per user?
I know I can limit the number of connections and number of queries per user, but before enforcing limits, I want to know what the current numbers are.
How can this be measured (in MySQL 5.7)?
Best Answer
The performance schema provides statistics aggregated by account (user + host), by user, and by host.
See for example table:
Reference manual https://dev.mysql.com/doc/refman/5.7/en/statement-summary-tables.html
This table will show statement statistics (aka, queries) broken down per account ... anyone causing heavy traffic (high number of queries) or expensive computation (a few very expensive and long latencies queries) should be very visible in these statistics.
[Edit] Example of query:
will show how many queries each account do, ordered by count descending.