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 `es_temp1` ADD INDEX `es_temp1_idx_name_bib_timed_categ_total_categ` (`Name`,`BIB`,`TimeDerived`,`CategoryName`,`TotalPace`,`Category`);
ALTER TABLE `es_temp2` ADD INDEX `es_temp2_idx_category` (`Category`);
SELECT
UCASE(g1.Name) Name,
g1.BIB,
g1.TimeDerived,
g1.CategoryName,
g1.TotalPace,
g1.Category,
COUNT(*) AS rank
FROM
es_temp1 g1
JOIN
es_temp2 g2
ON (
g2.TimeDerived,
g2.bib) <= (g1.TimeDerived,
g1.bib)
AND g1.Category = g2.Category
WHERE
1 = 1
AND 1 = 1
GROUP BY
g1.Name,
g1.BIB,
g1.TimeDerived,
g1.CategoryName,
g1.TotalPace,
g1.Category
ORDER BY
g1.Category,
rank