Very slow MySQL code (inline and JOINS) -


how can restructure query below run faster? takes several minutes run, slows down webserver significantly. query gets details of product several tables, using inline queries , joins. have feeling there must faster way.

what efficient way of writing query below?

select p.*,     pd.*, pd.name name, pi.*,p.image default_image,     (select first  product_shipping psi       psi.product_id = p.product_id)         flat_rate,     (select name   manufacturer m       m.manufacturer_id = p.manufacturer_id) manufacturer,     (select price   product_special ps       ps.product_id = p.product_id , ps.customer_group_id = 8) special_price       product p        left join product_description pd            on ( p.product_id = pd.product_id )        left join product_image pi            on ( p.product_id = pi.product_id )      order  p.product_id  

a bit of items in select duplicated, since that's how getting data originally, i've kept is. also, using left joins can slower inner joins:

select      product.*,     product_description.*,     product_description.name name,     product_image.*,     product.image default_image,     product_shipping.first flat_rate,     manufacturer.name manufacturer,     product_special.price special_price     product         left join product_description on product.product_id = product_description.product_id         left join product_image on product_image.product_id = product_image.product_id         left join manufacturer on product.manufacturer_id = manufacturer.id         left join product_special on product.product_id = product_special.product_id , product_special.customer_group_id = 8 order product.product_id 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -