After I have seen that some 3rd party modules duplicate the core_url_rewrite
table to store there additional category rewrite information in it (1), I came to the conclusion that it should be save to remove the joinLeft()
in the flat table classes.
Instead of the joinLeft()
you simply refer to the column main_table.url_path as request_path
in the tables catalog_category_flat_store_[StoreId]
. Please see the new methods.
Downside: To get the correct rewrites in the frontend you need to run the reindex for catalog_category_flat
. During this reindex the correct rewrites will be inserted into the column catalog_category_flat_store_X.url_path
.
Footnotes:
(1) the join with the core_url_rewrite
takes for large product collection really long when you only need the correct rewrite for the categories. This can save per request around ~0.Xsec.
Btw: in Mage_Catalog_Block_Seo_Sitemap_Product::_prepareLayout()
the collection is loaded without any join on core_url_rewrite
so each product listed will create a select like:
SELECT `core_url_rewrite`.* FROM `core_url_rewrite` WHERE (`core_url_rewrite`.`id_path`='product/158') AND (store_id IN(0, '2')) ORDER BY `store_id` DESC LIMIT 1
I added also a Database Index into the core_url_rewrite Table:
https://github.com/mklooss/Loewenstark_UrlIndexer/blob/master/app/code/community/Loewenstark/UrlIndexer/sql/urlindexer_setup/install-1.0.0.0.php#L16