Jump to content

Query takes ages


c_pattle

Recommended Posts

I have the following query that takes 69 seconds, which I reckon is going to be a tad bit too slow to use on a public facing website  :P .  I was wondering if anyone knows how I can speed up the query. 

 

SELECT product_data.*, products.supplier_ref, product_pricing.sales_price_inc_vat, products.type_id, MATCH(product_data.product_name) AGAINST ("Metacam") AS score FROM product_data, products, product_pricing WHERE products.type_id = 1 AND product_data.product_id=products.product_id AND product_data.product_id=product_pricing.product_id  AND products.type_id = 1 ORDER BY score DESC LIMIT 20

 

Let me know if you want me to put the table structures on here but they are quite big!

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/252824-query-takes-ages/
Share on other sites

Thanks, this was the results

 

id select_type table type possible_keys key key_len ref rows Extra

1 SIMPLE product_data ALL NULL NULL NULL NULL 12432 Using temporary; Using filesort

1 SIMPLE product_pricing ALL NULL NULL NULL NULL 5558 Using where

1 SIMPLE products eq_ref PRIMARY PRIMARY 4 animed.product_data.product_id 1 Using where

 

So I guess I need to add some indexes?

Link to comment
https://forums.phpfreaks.com/topic/252824-query-takes-ages/#findComment-1297037
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.