In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `agentstatusinformation` ADD INDEX `agentstatusinforma_idx_userid_pkey` (`userid`,`pkey`);
ALTER TABLE `axpuser` ADD INDEX `axpuser_idx_pkey` (`pkey`);
SELECT
DISTINCT (SELECT
axpuser.loginid
FROM
axpuser
WHERE
axpuser.pkey = age.userid),
CASE
WHEN age.agentstate = 1 THEN 'Ready'
WHEN age.agentstate = 3 THEN 'Pause' END AS state
FROM
agentstatusinformation age
WHERE
(
age.userid, age.pkey
) IN (
SELECT
agentstatusinformation.userid,
max(agentstatusinformation.pkey)
FROM
agentstatusinformation
GROUP BY
agentstatusinformation.userid
ORDER BY
NULL
)