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 `adstable` ADD INDEX `adstable_idx_adacti_approv_target_target_adbudg` (`adactive`,`approved`,`targetdesktop`,`targetwindows`,`adbudget`);
ALTER TABLE `adstable` ADD INDEX `adstable_idx_imp_today` (`imp_today`);
ALTER TABLE `userstable` ADD INDEX `userstable_idx_balance` (`balance`);
SELECT
adstable_adid
FROM
(SELECT
adstable.adid AS adstable_adid,
adstable.user AS adstable_user
FROM
adstable
WHERE
adstable.adactive = 1
AND adstable.approved = 1
AND adstable.targetdesktop = 1
AND adstable.targetwindows = 1
AND adstable.adbudget > 0.02
ORDER BY
adstable.imp_today ASC LIMIT 1) AS adstable
INNER JOIN
userstable
ON (
adstable.adstable_user = userstable.id
)
WHERE
1 = 1
AND 1 = 1
AND 1 = 1
AND 1 = 1
AND 1 = 1
AND userstable.balance > 0.02 LIMIT 1