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 `account_location` ADD INDEX `account_location_idx_location_a_account_id` (`location`,`A`,`account_id`);
ALTER TABLE `account_tax` ADD INDEX `account_tax_idx_tax_id` (`tax_id`);
ALTER TABLE `tax` ADD INDEX `tax_idx_account_id` (`account_id`);
SELECT
a.account_id,
a.account,
b.tax,
b.rate
FROM
accounts AS a
LEFT JOIN
tax AS b
ON a.account_id = b.account_id
AND EXISTS (
SELECT
1
FROM
account_tax
WHERE
(
EXISTS (
SELECT
1
FROM
account_location
WHERE
(
account_location.location = account_location."A"
)
AND (
account_tax.account_id = account_location.account_id
)
)
)
AND (
b.tax_id = account_tax.tax_id
)
)
WHERE
(
EXISTS (
SELECT
1
FROM
account_location
WHERE
(
account_location.location = account_location."A"
)
AND (
a.account_id = account_location.account_id
)
)
)