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:
SELECT
*
FROM
Table_A a
LEFT JOIN
Table_B b
ON a.r_id = b.r_id
ORDER BY
IF(b.fooData = 'A',
CAST(result AS DECIMAL (4,
3)),
myCastFunction(result)) ASC LIMIT 1