LONGMAN
Dark Side of the Moon..
Оптимизация запроса
запрос:
Explain:
Для вывода 10 записей перебирать 4591 это нормально?
P.S. Как тут нормально оформить SQL код и Explain?
запрос:
PHP:
SELECT `p`.*
FROM `shoppingcart_products` AS `p`
LEFT JOIN `shoppingcart_products_data` AS `d` ON `p`.`id` = `d`.`itemid`
LEFT JOIN `shoppingcart_products_categories` AS `pc` ON `pc`.`pid` = `p`.`id`
LEFT JOIN `shoppingcart_categories` AS `cc` ON `cc`.`id` = `pc`.`cid`
LEFT JOIN `shoppingcart_currency` AS `cur` ON `cur`.`id` = `p`.`currency`
LEFT JOIN `shoppingcart_manufacturers_data` AS `m` ON `m`.`itemid` = `p`.`manufacturer`
LEFT JOIN `shoppingcart_users` AS `u` ON `u`.`id` = `p`.`added_by`
GROUP BY `p`.`id`
ORDER BY `p`.`date` DESC
LIMIT 10
PHP:
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE p index NULL date 8 NULL 4591 Using temporary
1 SIMPLE d ref itemid itemid 4 shopdb.p.id 2 Using index
1 SIMPLE pc ref PRIMARY PRIMARY 4 shopdb.p.id 2 Using index
1 SIMPLE cc eq_ref PRIMARY PRIMARY 4 shopdb.pc.cid 1 Using index
1 SIMPLE cur eq_ref PRIMARY PRIMARY 4 shopdb.p.currency 1 Using index
1 SIMPLE m ref itemid itemid 4 shopdb.p.manufacturer 1 Using index
1 SIMPLE v eq_ref PRIMARY PRIMARY 4 shopdb.p.added_by 1 Using index
P.S. Как тут нормально оформить SQL код и Explain?