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 `all_sent_Orders` ADD INDEX `all_orders_idx_nachforschungcompletedon` (`nachforschungCompletedOn`);
SELECT
*
FROM
all_sent_Orders a
WHERE
a.nachforschungCompletedOn IS NULL
AND CASE
WHEN a.lastMessageSent IS NOT NULL
AND a.lastResponse IS NULL THEN date(date_sub(current_date, INTERVAL 7 DAY)) = date(a.lastMessageSent)
ELSE (
date(date_sub(current_date, INTERVAL 30 DAY)) = date(IFNULL(a.lastResponse, a.nachforschungSentOn))
OR date(date_sub(current_date, INTERVAL 60 DAY)) = date(IFNULL(a.lastResponse, a.nachforschungSentOn))
OR date(date_sub(current_date, INTERVAL 90 DAY)) = date(IFNULL(a.lastResponse, a.nachforschungSentOn))
OR date(date_sub(current_date, INTERVAL 120 DAY)) = date(IFNULL(a.lastResponse, a.nachforschungSentOn))
) END