From outside MySQL, I know I can do many things to know what the CPU usage of a process is, ie. top.
But, from an internal standpoint, I would like to know if it is possible to run a query from MySQL to know what the system CPU is or the CPU consumption of the current thread is.
I'm running massive queries nightly through the Event Scheduler and my DB server gets stuck at 100% CPU for a few minutes blocking or slowing down users around the globe.
I've tried to research a way to limit CPU usage by thread or user, but it doesn't seem to be possible yet.
So, I'm trying to do something along the lines of the following in my Event:
IF (SELECT CPU_USAGE() > 0.8) THEN
REPEAT
SLEEP(0.01);
UNTIL (SELECT CPU_USAGE() < 0.25)
END REPEAT;
END IF;
Obviously CPU_USAGE() doesn't exist, but if there is something similar I can do to accomplish a similar effect, I'm all ears. Thanks.
P.S. I'm on Amazon RDS