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 `orders_status_history` ADD INDEX `orders_history_idx_orders_id_orders_id` (`orders_id`,`orders_status_id`);
SELECT
*
FROM
orders_status_history
WHERE
NOT EXISTS (
SELECT
1
FROM
orders_status_history AS orders_status_history1
WHERE
(
orders_status_history1.orders_status_id = 3
)
AND (
orders_status_history.orders_id = orders_status_history1.orders_id
)
)