MySQL Forums
Forum List  »  Optimizer & Parser

Very slow query, help please
Posted by: Jaume Roca
Date: January 29, 2013 10:18AM

Hello everyone.

I have a very slow query (33.1319 seconds) and I don't know if there is a solution for this:

select proveidors_treballadors.id_prov_treb, nom, coalesce(fac,0) from proveidors_treballadors
left join (select id_prov_treb, ROUND((sum(materials+stock)),2) as fac from albarans 
left join (select id_albara, sum(quantitat*multiplicatiu) as materials from comandes_albarans_families group by id_albara)
    T1 on (albarans.id_albara=T1.id_albara)
left join (select id_albara, sum(quantitat*multiplicatiu) as stock from albarans_families group by id_albara)
    T2 on (albarans.id_albara=T2.id_albara) 
group by id_prov_treb)
T3 on (proveidors_treballadors.id_prov_treb=T3.id_prov_treb)
where tipus_prov_treb = 'proveidor';

The query explain is



And design for data base, the tables are in yellow color:



Thank you!

Options: ReplyQuote


Subject
Views
Written By
Posted
Very slow query, help please
2807
January 29, 2013 10:18AM
1550
January 30, 2013 05:12AM
1503
January 30, 2013 08:38AM
1524
January 30, 2013 09:05AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.