SELECT
pvl.name_parametre_value_parametre_value_lang,
pv.id_parametre_value,
ic.id_combinaison,
ic.prix_combinaison,
ic.poid_combinaison,
ic.actif_combinaison,
ic.actif_genere,
pv.actif_value,
pipv.id_parametre_value as pipv_id_parametre_value
FROM
ps_imp_combinaison_parametre_value_6 cpv
LEFT JOIN ps_imp_combinaison_6 ic ON ic.id_combinaison = cpv.id_combinaison
LEFT JOIN ps_imp_parametre_value pv ON pv.id_parametre_value = cpv.id_parametre_value
LEFT JOIN ps_imp_parametre_value_lang pvl ON pvl.id_parametre_value = pv.id_parametre_value
LEFT JOIN ps_imp_parametre p ON p.id_parametre = pv.id_parametre
LEFT JOIN ps_imp_product_impression_parametre_value pipv ON pipv.id_parametre_value = pv.id_parametre_value and pipv.id_product_impression = 63
WHERE
p.id_nom_domaine = 6
AND
pvl.id_lang_domaine = 18
AND
ic.id_product_impression = 63
GROUP BY
ic.id_combinaison,
cpv.id_parametre_value
ORDER BY
ic.id_combinaison,
p.id_parametre
LIMIT
0, 50
The following query is taking too much time (more than 4 minutes). Is there a way to make it faster?
ps_imp_combinaison has 97290 lignes ps_imp_combinaison_parametre_value has 705595 lignes
Your query contains a lot of joins, which will always increased the amount of time it takes to extract the information. There is no easy way to speed up what you have, since you already apply a limit to the total results, and the limit does not appear to be easily applied earlier.
Your best potential for reducing the time is through looking at the logic behind what you are pulling, and see if you can reduce the number of joins. As well as that, see if you can apply a limit before joining with a sub query like this:
SELECT * FROM
(SELECT * FROM table_1 LIMIT 50) as subq
LEFT JOIN ...
This may help reduce the complexity of later joins.
Do you have any indexes defined? You would definitely want an index on the ps_imp_combinaison
table column id_combinaison
and on the ps_imp_combinaison_parametre_value
table column id_combinaison
as that is the main join criteria on your presumably largest tables.
Then additional indexes on criteria columns may be helpful. Just remember there is a trade-off of indexes; the more indexes, the longer inserts/updates/deletes take, but they can make that 4 minute query become a 4 second query probably.
SELECT
pvl.name_parametre_value_parametre_value_lang,
pv.id_parametre_value,
pipv.id_parametre_value as pipv_id_parametre_value
FROM
ps_imp_combinaison_parametre_value_6 cpv
LEFT JOIN ps_imp_combinaison_6 ic ON ic.id_combinaison = cpv.id_combinaison
LEFT JOIN ps_imp_parametre_value pv ON pv.id_parametre_value = cpv.id_parametre_value
LEFT JOIN ps_imp_parametre_value_lang pvl ON pvl.id_parametre_value = pv.id_parametre_value
LEFT JOIN ps_imp_parametre p ON p.id_parametre = pv.id_parametre
LEFT JOIN ps_imp_product_impression_parametre_value pipv ON pipv.id_parametre_value = pv.id_parametre_value and pipv.id_product_impression = 63
WHERE
p.id_nom_domaine = 6
AND
pvl.id_lang_domaine = 18
AND
ic.id_product_impression = 63
GROUP BY
ic.id_combinaison,
cpv.id_parametre_value
ORDER BY
ic.id_combinaison,
p.id_parametre
LIMIT
0, 50
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.