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 `customer` ADD INDEX `customer_idx_customer_id` (`customer_id`);
ALTER TABLE `payment` ADD INDEX `payment_idx_customer_id` (`customer_id`);
SELECT
c.customer_id,
c.first_name,
SUM(p.amount) total,
COUNT(p.amount) n_payments
FROM
customer c
INNER JOIN
payment p
ON c.customer_id = p.customer_id
GROUP BY
c.customer_id
ORDER BY
n_payments DESC