Ottimizzare una query

etttorina

Nuovo Utente
20 Giu 2007
10
0
0
Salve,
ho un grande problema con questa query:
PHP:
// QUERY 
$query_sql = "SELECT
p.products_id, 
p2c.categories_id, 
m.manufacturers_name, 
pd.products_name, 
pd.products_description, 
p.products_quantity, 
p.products_image, 
p.products_tax_class_id, 
t.tax_rate, 
IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, 
IF(s.status, s.specials_new_products_price, p.products_price) AS final_price
FROM " . TABLE_PRODUCTS . " AS p 
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " AS pd ON p.products_id = pd.products_id 
LEFT JOIN " . TABLE_PRODUCTS_TO_CATEGORIES . " AS p2c ON p.products_id = p2c.products_id 
LEFT JOIN " . TABLE_MANUFACTURERS . " AS m ON m.manufacturers_id = p.manufacturers_id 
LEFT JOIN " . TABLE_SPECIALS . " AS s on p.products_id = s.products_id 
LEFT JOIN tax_rates AS t on t.tax_class_id = p.products_tax_class_id 
WHERE 
p.products_id = pd.products_id AND 
p.products_id = p2c.products_id AND 
p.products_status = '1' AND 
pd.language_id = '" . $language_id . "' 
GROUP BY p.products_id 
ORDER BY p2c.categories_id, pd.products_name";


$result = mysql_query( $query_sql );

Siccome restituirebbe circa 9000 records ma è troppo pesante e mi va in errore 500,
avrei bisogno di dividerla in più query.
So di dover utilizzare la funzione LIMIT ma non riesco a scriverla...
Qualcuno può darmi una mano?
Grazie mille
 

Discussioni simili