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 `#listingsTemp` ADD INDEX `listingstemp_idx_code_fap_classifica` (`code`,`fap`,`classification_id`);
SELECT
1
FROM
#listingsTemp lt1,
#listingsTemp lt2
WHERE
lt1.code = lt2.code
AND lt1.classification_id > lt2.classification_id
AND (
lt1.fap < lt2.fap
OR lt1.fap = lt2.fap
)