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 `citizens_history` ADD INDEX `citizens_history_idx_update_to` (`update_id_to`);
ALTER TABLE `citizens_history` ADD INDEX `citizens_history_idx_experience` (`experience`);
SELECT
ch1.*
FROM
(SELECT
citizens_history1.id AS citizens_history1_id,
citizens_history1.update_id_to AS citizens_history1_update_id_to
FROM
citizens_history AS citizens_history1
ORDER BY
citizens_history1.experience DESC LIMIT 100) AS citizens_history1
LEFT JOIN
citizens_history AS citizens_history2
ON (
citizens_history2.id = citizens_history1.citizens_history1_id
)
AND (
citizens_history1.citizens_history1_update_id_to < citizens_history2.update_id_to
)
WHERE
(
1 = 1
)
AND (
citizens_history2.update_id_to IS NULL
) LIMIT 100