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 `a` ADD INDEX `a_idx_userid_date` (`userid`,`date`);
ALTER TABLE `a` ADD INDEX `a_idx_date` (`date`);
ALTER TABLE `b` ADD INDEX `b_idx_agencyid` (`agencyid`);
SELECT
a_status,
a_title,
a_id,
b.deployed,
b.accepted,
b.rejected,
b.error
FROM
(SELECT
a.status AS a_status,
a.title AS a_title,
a.id AS a_id
FROM
a
WHERE
a.userid = 3
ORDER BY
a.date DESC LIMIT 50) AS a
INNER JOIN
b
ON (
a.a_id = b.id
)
WHERE
b.agencyid = 1
AND 1 = 1 LIMIT 50