|
And here the teaked query that did better in terms of timing::
select ee.*, IFNULL(_table_name.value, _table_name_default.value) AS
`name`, `_table_price`.`value` AS `price`,
IFNULL(_table_small_image.value, _table_small_image_default.value) AS
`small_image`, `_table_special_price`.`value` AS `special_price`,
IFNULL(_table_special_from_date.value,
_table_special_from_date_default.value) AS `special_from_date`,
IFNULL(_table_special_to_date.value,
_table_special_to_date_default.value) AS `special_to_date`,
IFNULL(_table_status.value, _table_status_default.value) AS `status`,
IFNULL(_table_visibility.value, _table_visibility_default.value) AS
`visibility`
FROM
(SELECT `e`.*, IFNULL(_table_news_from_date.value,
_table_news_from_date_default.value) AS `news_from_date`,
IFNULL(_table_news_to_date.value, _table_news_to_date_default.value) AS
`news_to_date`
FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_product_entity_datetime` AS
`_table_news_from_date_default` ON
(_table_news_from_date_default.entity_id = e.entity_id) AND
(_table_news_from_date_default.attribute_id=’66’) AND
_table_news_from_date_default.store_id=0
LEFT JOIN `catalog_product_entity_datetime` AS `_table_news_from_date`
ON (_table_news_from_date.entity_id = e.entity_id) AND
(_table_news_from_date.attribute_id=’66’) AND
(_table_news_from_date.store_id=’1’)
LEFT JOIN `catalog_product_entity_datetime` As
`_table_news_to_date_default` ON (_table_news_to_date_default.entity_id
= e.entity_id) AND (_table_news_to_date_default.attribute_id=’67’) AND
_table_news_to_date_default.store_id=0
LEFT JOIN `catalog_product_entity_datetime` AS `_table_news_to_date` ON
(_table_news_to_date.entity_id = e.entity_id) AND
(_table_news_to_date.attribute_id=’67’) AND
(_table_news_to_date.store_id=’1’)
WHERE (e.entity_type_id = ‘4’) AND
(IFNULL(_table_news_from_date.value,
_table_news_from_date_default.value) <= ‘2008-06-03’) AND
((IFNULL(_table_news_to_date.value, _table_news_to_date_default.value)
>= ‘2008-06-03’) OR (_table_news_to_date.value is null)) ORDER BY `_table_news_from_date`.`value` desc,
`_table_news_from_date`.`value` desc LIMIT 5) as ee
INNER JOIN `catalog_product_entity_varchar` AS `_table_name_default` ON
(_table_name_default.entity_id = ee.entity_id) AND
(_table_name_default.attribute_id=’45’) AND _table_name_default.store_id=0
LEFT JOIN `catalog_product_entity_varchar` AS `_table_name` ON
(_table_name.entity_id = ee.entity_id) AND
(_table_name.attribute_id=’45’) AND (_table_name.store_id=’1’)
INNER JOIN `catalog_product_entity_decimal` AS `_table_price` ON
(_table_price.entity_id = ee.entity_id) AND
(_table_price.attribute_id=’49’) AND (_table_price.store_id=0)
INNER JOIN `catalog_product_entity_varchar` AS
`_table_small_image_default` ON (_table_small_image_default.entity_id =
ee.entity_id) AND (_table_small_image_default.attribute_id=’60’) AND
_table_small_image_default.store_id=0
LEFT JOIN `catalog_product_entity_varchar` AS `_table_small_image` ON
(_table_small_image.entity_id = ee.entity_id) AND
(_table_small_image.attribute_id=’60’) AND (_table_small_image.store_id=’1’)
LEFT JOIN `catalog_product_entity_decimal` AS `_table_special_price` ON
(_table_special_price.entity_id = ee.entity_id) AND
(_table_special_price.attribute_id=’50’) AND
(_table_special_price.store_id=0)
LEFT JOIN `catalog_product_entity_datetime` AS
`_table_special_from_date_default` ON
(_table_special_from_date_default.entity_id = ee.entity_id) AND
(_table_special_from_date_default.attribute_id=’51’) AND
_table_special_from_date_default.store_id=0
LEFT JOIN `catalog_product_entity_datetime` AS
`_table_special_from_date` ON (_table_special_from_date.entity_id =
ee.entity_id) AND (_table_special_from_date.attribute_id=’51’) AND
(_table_special_from_date.store_id=’1’)
LEFT JOIN `catalog_product_entity_datetime` AS
`_table_special_to_date_default` ON
(_table_special_to_date_default.entity_id = ee.entity_id) AND
(_table_special_to_date_default.attribute_id=’52’) AND
_table_special_to_date_default.store_id=0
LEFT JOIN `catalog_product_entity_datetime` AS `_table_special_to_date`
ON (_table_special_to_date.entity_id = ee.entity_id) AND
(_table_special_to_date.attribute_id=’52’) AND
(_table_special_to_date.store_id=’1’)
INNER JOIN `catalog_product_entity_int` AS `_table_status_default` ON
(_table_status_default.entity_id = ee.entity_id) AND
(_table_status_default.attribute_id=’69’) AND
_table_status_default.store_id=0
LEFT JOIN `catalog_product_entity_int` AS `_table_status` ON
(_table_status.entity_id = ee.entity_id) AND
(_table_status.attribute_id=’69’) AND (_table_status.store_id=’1’)
INNER JOIN `catalog_product_entity_int` AS `_table_visibility_default`
ON (_table_visibility_default.entity_id = ee.entity_id) AND
(_table_visibility_default.attribute_id=’74’) AND
_table_visibility_default.store_id=0
LEFT JOIN `catalog_product_entity_int` AS `_table_visibility` ON
(_table_visibility.entity_id = ee.entity_id) AND
(_table_visibility.attribute_id=’74’) AND
(_table_visibility.store_id=’1’);
|