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 `priorities` ADD INDEX `priorities_idx_priority_id` (`priority`,`id`);
SELECT
p1.*,
COUNT(p2.id) AS before_me_same_priority
FROM
priorities AS p1
LEFT JOIN
priorities AS p2
ON p1.priority = p2.priority
AND p1.id > p2.id
GROUP BY
p1.id
ORDER BY
before_me_same_priority,
p1.priority