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 `customers` ADD INDEX `customers_idx_name` (`name`);
ALTER TABLE `customers_addresses` ADD INDEX `customers_addresse_idx_id_customer` (`id_customer`);
ALTER TABLE `customers_contacts` ADD INDEX `customers_contacts_idx_id_customer` (`id_customer`);
SELECT
customers_id_customer,
customers_name,
X.contact AS contact,
Y.street,
Y.zipcode,
Y.city
FROM
(SELECT
customers.id_customer AS customers_id_customer,
customers.name AS customers_name
FROM
customers
ORDER BY
customers.name DESC LIMIT 20) AS customers
LEFT JOIN
(
SELECT
GROUP_CONCAT(CONCAT(customers_contacts.type,
': ',
customers_contacts.value) SEPARATOR ', ') AS contact,
customers_contacts.id_customer
FROM
customers_contacts
GROUP BY
customers_contacts.id_customer
ORDER BY
NULL
) AS X
ON X.id_customer = customers.customers_id_customer
INNER JOIN
(
SELECT
GROUP_CONCAT(street SEPARATOR '
') AS street,
GROUP_CONCAT(zipcode SEPARATOR '
') AS zipcode,
GROUP_CONCAT(city SEPARATOR '
') AS city,
customers_addresses.id_customer
FROM
customers_addresses
GROUP BY
customers_addresses.id_customer
ORDER BY
NULL
) AS Y
ON Y.id_customer = customers.customers_id_customer
WHERE
Y.street LIKE '%Avenue%' LIMIT 20