MySQL Forums
Forum List  »  Optimizer & Parser

Re: Very slow query, help please
Posted by: Jaume Roca
Date: January 30, 2013 09:05AM

Thank you for your suggestions I didn't know new mysql version features, but I think that I have the solution:

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

0.0463 seg, Is great :)

What do you think for this query?

Thank you so much.

Regards!

Options: ReplyQuote


Subject
Views
Written By
Posted
2828
January 29, 2013 10:18AM
1558
January 30, 2013 05:12AM
1510
January 30, 2013 08:38AM
Re: Very slow query, help please
1529
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.