MySql查询对于大量记录花费的时间太长

时间:2016-10-18 07:54:18

标签: mysql sql

这是我的查询

   SELECT IF(g.id !="",g.image,p.products_image) products_image
        , p.products_date_added
        , IF(g.id !="", CONCAT(pd.products_name, " - ",g.image_caption),pd.products_name) products_name
        , p.production_status
        , p.customers_id
        , p.products_quantity
        , g.id g_id
        , p.ean as pean
        , g.ean as gean
        , p.products_id
        , p.manufacturers_id
        , p.products_price
        , p.products_tax_class_id
        , IF(s.status, s.specials_new_products_price, NULL) specials_new_products_price
        , IF(s.status, s.specials_new_products_price, p.products_price) final_price 
     FROM products_description pd
        , products p 
     LEFT 
     JOIN gemstone_combination_images g 
       ON g.products_id = p.products_id 
     LEFT 
     JOIN manufacturers m 
       ON p.manufacturers_id = m.manufacturers_id 
     LEFT 
     JOIN specials_retail_prices s 
       ON p.products_id = s.products_id
        , products_to_categories p2c
    WHERE p.products_status = 1 
      AND p.products_id = p2c.products_id 
      AND pd.products_id = p2c.products_id 
      AND pd.language_id = 1

enter image description here

目前这个查询返回了超过14k的记录并花了将近1分钟来执行。随着数字记录的增加,将需要更多的加载时间。那么有人可以在我的查询中建议我进行优化吗?

由于

0 个答案:

没有答案