Makes indexing of your Magento store around x times faster! ‼️ Maintainers wanted!

Overview

FastIndexer

This module has never been used in production.

No more empty results in the frontend due to a long taking reindex process!

  • Integrates seamlessly into the existing Magento indexer process.
  • Does not change the core Magento indexer logic! (Except URL rewrite if you wish)
  • Only one class rewrite! (Adding an event in Mage_Index_Model_Process::reindexAll())
  • Indexing blocks the frontend for only ~0.003 seconds instead of minutes with the normal indexer.
  • The frontend will not be affected anymore by any reindex process.
  • Speeds up some indexing processes of your Magento store.
  • You can enable or disable the module in the backend and test the speed difference by yourself.
  • Full reindexing now even under high frontend load possible (Citation/Test needed ... ).
  • Limits the amount of SQL queries in some cases
  • Even integrates into your custom indexer processes (theoretically, talk to me).
  • Indexer (catalogpermissions & targetrule) for Enterprise Edition will also be considered
  • Removes "unnecessary" joins with url rewrite table in frontend selects (Requires Magento CE >= 1.8)

The FastIndexer is only available on the command line.

$ php/hhvm index.php reindexall

Configuration options (Backend)

Accessible via System -> Configuration -> System -> FastIndexer

Enable FastIndexer

Enable or disable the FastIndexer. This is useful to become yourself aware about the differences.

Drop old tables

Default values: YES. For testing purposes or in development you can disable that option.

Disabling it also means that the process might be a little bit slower and you are collecting tons of data by generating old index tables.

Shadow Databases

FastIndexer needs two Shadow Databases which must be on the same file system as the Magento store core database.

You have two text fields in the backend to enter the different names of the Shadow Databases.

The backend configuration section also checks for you if the current Magento core database user can access those two databases. If not it will display a warning. FastIndexer cannot create by itself those two databases automatically. Ask your DevOps for assistance.

Verifying Installation of PDO class

FastIndexer comes with a custom Pdo_MySQL PHP class which also fixes two evil bugs in the default Varien_Db_Adapter_Pdo_Mysql class. It is 100% compatible.

The FastIndexer PDO class must be configured in app/etc/local.xml.

If you have correctly installed the FastIndexer PDO class then a green sign shows up in the system configuration section otherwise you will see the installation instructions.

URL Rewrites: Copy all custom URLs

Enable this option if you wish to copy all custom URLs. Before enabling this option be sure that the permanent rewrite generating bug in Magento ~<=1.7 has been fixed. Otherwise you will add tens of thousands useless rewrites with each reindexing. If this option is disabled only the rewrites created by the store maintainer will be copied. But this can be slow because a regular expression will be used to determine all custom rewrites. If set to yes no regex will be used.

Checking for system generated custom redirect permanent URLs

With the following SQL Query you can check the system generated custom redirect permanent URLs:

SELECT * FROM `core_url_rewrite` WHERE is_system=0 AND id_path RLIKE '[0-9]+\_[0-9]+'

If that query returns nothing then you can set this option to Yes.

Checking for your custom created URLs

You can create custom URL redirects at Catalog -> URL Rewrite Management. With the following SQL Query you can check if you have custom URLs:

SELECT * FROM `core_url_rewrite` WHERE is_system=0 AND id_path NOT RLIKE '[0-9]+\_[0-9]+'

Configuration options (local.xml)

Changing the type instance

Please see the section Verifying Installation of PDO class above.

Low Level Optimization

This feature can be switched on even when FastIndexer is turned off.

Low Level Optimization tries to convert stringified integer or float values into real integer resp. float values. This features applies on all queries. E.g. converts a query from WHERE entity_id IN('433284', 433283) to WHERE entity_id IN(433284, 433283) because mixing strings and integer values in a query will MySQL slow down. Query 1 needs: 0.0566s and optimized 0.0008s.

Use at your own risk. Test thoroughly.

To enable the low level quote() method optimization edit your local.xml and add the following entry in the node: config/global/resources/default_setup/connection/fiQuoteOpt. Use for node fiQuoteOpt the value 1 for enable or any other value for disabled.

<config>
    <global>
		...
        <resources>
            ...
            <default_setup>
                <connection>
                    <host><![CDATA[localhost]]></host>
                    <username>...</username>
					...

                    <!--FastIndexer quote() optimization: 1/0-->
                    <fiQuoteOpt>1</fiQuoteOpt>

                </connection>
            </default_setup>
        </resources>
    </global>
</config>

It must be set in the local.xml file because quote() method is called even before the Magento configuration is available.

How do the Magento default indexer work? (Full reindex)

Investigation of the logged SQL statements: Most indexer are completely deleting the index tables. Some of them only for a store view. But both cases are equal because each time the frontend customer has no access to the data (prices, stocks, search results ...) and gets empty results. Lost a customer and made less profit :-(

Explaining the operation of FastIndexer

All index processes have one thing in common: They block the frontend during their whole index duration. That's why many store owners run a full reindex only during the night or even more seldom.

Some indexer truncates the index tables. If in that moment a potential customer wants to buy something he/she will fail because of empty tables.

Some indexer are doing complex operations for calculating differences between already indexed data and new data. This costs a lot of time and the index tables have a lock for updates.

Technial Explanations

Reindexing will be done in the so called Shadow Databases.

Therefore the table swapping operation is done atomically after the reindexing, which means that no other session can access any of the index/flat tables while the swapping is running.

This swapping operation needs ~0.003 seconds.

If there are any database triggers associated with an index/flat table which is swapped to a different Shadow Database, then the swapping operation will fail.

When the swapping operation is running and there are any locked tables or active transactions then the swapping will fail.

If the swapping fails nothing will break. Just rerun the indexer.

The current Magento database user must also have the ALTER and DROP privileges on the original table, and the SELECT,ALTER,DROP,CREATE and INSERT privileges on the new tables in the Shadow Databases.

Performance

On my MacBook Air Mid 2012 tested with the following stores.

Condition for all tests:

  • No load on the frontend.
  • Just indexing of previous reindexed tables.
  • All indexe commands ran 3x and the median has been calculated.
  • SET GLOBAL query_cache_type=OFF; has been set.
  • At the 4th run all queries have been counted in Zend_Db_Statement_Pdo::_execute().
$ time -p php indexer.php --reindex <code>

Magento 1.8 default installation

  • 3 store views
  • 27 categories
  • 120 products
Type FastIndexer real user sys Query Count
reindexall x 14.209s 5.836s 0.370s 3275
reindexall ✔︎ 7.490s 4.265s 0.179s 2702

Shop 03: Magento EE 1.12

  • 3 store views
  • 66 categories
  • 14088 products
Type FastIndexer real user sys Query Count
catalog_product_attribute x 29.69s 8.14s 0.40s 208
... ✔︎ 34.18s 8.39s 0.42s 243
catalog_product_price x 10.71s 1.56s 0.07s 173
... ✔︎ 9.64s 1.63s 0.07s 248
catalog_product_flat x 184.31s 4.74s 0.58s 1,570
... ✔︎ 167.26s 2.60s 0.11s 530
catalog_category_flat x 2.43s 1.84s 0.07s 80
... ✔︎ 2.52s 1.84s 0.07s 113
catalog_category_product x 70.37s 1.91s 0.07s 117
... ✔︎ 31.46s 2.09s 0.08s 138
catalogsearch_fulltext x 114.91s 2.21s 0.07s 8,769
... ✔︎ 114.24s 2.76s 0.08s 8,774
cataloginventory_stock x 3.36s 1.50s 0.06s 32
... ✔︎ 3.16s 1.38s 0.06s 47
catalog_url (~245177 URLs) x 858.11s 637.34s 60.95s 524,748*
... ✔︎ 819.44s 574.90s 53.25s 494,411
  • added 3701 additional URLs due to the rewrite bug in the URL indexer

Shop 08: Magento EE 1.12

  • 4 store views
  • ~ 240 categories
  • ~ 5000 products
Type FastIndexer real user sys Query Count
catalog_product_attribute x 0.00s 0.00s 0.00s 0

Shop 26: Magento 1.7

  • One store view
  • ~ 15.500 categories
  • ~ 45.400 products
FastIndexer real user sys Query Count
Disabled 14m8.919s 5m0.248s 0m9.695s @todo
Enabled 10m37.517s 4m51.361s 0m8.864s @todo

About/History

Extension key: SchumacherFM_FastIndexer

Version 0.0.1

  • Initial Release
  • Not ready for production, WIP.

Compatibility

  • Magento CE >= 1.6.2
  • php >= 5.3.0

The FastIndexer will not run with Magento CE < 1.6.2 because elementary events are missing. If you are interested in running FastIndexer with lower Magneto version write me, there is a solution.

Support / Contribution

Report a bug using the issue tracker.

Licence

Apache License 2.0

Author

Cyrill Schumacher

My pgp public key

Made in Sydney, Australia :-)

You might also like...
Magento 2 Blog Extension - FREE, fully featured, powerful Blog solution for your online store!

Blog MX | Magento 2 Blog Module by Mirasvit FREE, fully featured, powerful Blog solution for your online store! Magento 2 Blog MX allows you to open a

Magento 2 Blog is an extension that allows you to manage your store and blog
Magento 2 Blog is an extension that allows you to manage your store and blog

Magento 2 Blog Extension by Magefan Magento 2 Blog is an extension that allows you to manage your store and blog from one place without having to rely

Magento extension which makes it impossible for a customer to log in until the account has been activated by the administrator.

This Magento 1 extension is orphaned, unsupported and no longer maintained. If you use it, you are effectively adopting the code for your own project.

A PHP Library To Make Your Work Work Easier/Faster

This Is A Php Library To Make Your Work Easier/Faster,

Magento 2 Extension to cleanup admin menu and Store > Configuration area by arranging third party extension items.
Magento 2 Extension to cleanup admin menu and Store Configuration area by arranging third party extension items.

Clean Admin Menu - Magento 2 Extension It will merge all 3rd party extension's menu items in backend's primary menu to a common menu item named "Exten

Magento 2 Preview/Visit Catalog allows the store owner to quickly preview the catalog (product & category) pages from the admin panel.
Magento 2 Preview/Visit Catalog allows the store owner to quickly preview the catalog (product & category) pages from the admin panel.

Magento 2 Preview/Visit Catalog Overview Magento 2 Preview/Visit Catalog allows the store owner to quickly preview the catalog (product & category) pa

Magento sample data includes a sample store, complete with more than 250 products

Magento sample data includes a sample store, complete with more than 250 products (about 200 of them are configurable products), categories, promotional price rules, CMS pages, banners, and so on. Sample data uses the Luma theme on the storefront.

LaraNx Seo enables your Laravel app to store SEO and social media meta tag data in database instead of your code
LaraNx Seo enables your Laravel app to store SEO and social media meta tag data in database instead of your code

LaraNx Seo enables your Laravel app to store SEO and social media meta tag data in database instead of your code. Moving marketing data out of your code base and into your database where it is easily modified.

Debug with Ray to fix problems faster
Debug with Ray to fix problems faster

Debug with Ray to fix problems faster This package can be installed in any PHP application to send messages to the Ray app. The desktop app: can be us

Comments
  • not ready yet?

    not ready yet?

    Hi,

    I get: PHP message: PHP Fatal error: Class name must be a valid object or a string in /www/fashionsport.ro_test/app/code/core/Mage/Core/Model/Resource.php on line 215 when I enable in local.xml

    opened by mmmgigi 2
  • Default file based locks don't work

    Default file based locks don't work

    You have:

            $userModel = Mage::getStoreConfig('fastindexer/indexer/lock_model');
            if (true === empty($userModel) || false === $this->getFiHelper()->isEnabled()) {
                $this->_lockInstance = false;
                return false;
            }
    

    And since the default file lock has no value (empty check returns true), it will not work - Fatal error: Call to a member function isLockExists() on a non-object in ...app\code\core\Mage\Index\Model\Process.php on line 480

    opened by TivoSoho 10
  • table prefixes are not working

    table prefixes are not working

    Hi,

    It looks like the table prefixes are not supported yet :) For example I have the following error when I execute "php indexer.php --reindex catalog_category_flat" :

    Base table or view not found: 1146 Table 'magento_test.catalog_category_entity' doesn't exist' in /www/magento_test/lib/Zend/Db/Statement/Pdo.php:228

    My db table prefix is "prefix_" .

    Question: What file(s) I have to edit and manually add my prefix value?

    Thank you for your great addon!

    opened by mmmgigi 1
Owner
Cyrill Schumacher
Golang all the time 🤘. Specialised in the eCommerce sector since 1998. Senior Gopher at microservice shop https://www.globus.ch
Cyrill Schumacher
WordPlate is a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate is simply a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate 1.7k Dec 24, 2022
A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2

Simple Import / Export tool A tool that allows to quickly export data from Magento 1 and Magento 2 store and import it back into Magento 2. Table data

EcomDev B.V. 51 Dec 5, 2022
Search faster into Magento DevDocs and Magento StackExchange! 🔍⚡️

VS Code - Magento DevSearch Search faster into Magento DevDocs and Magento StackExchange! ?? ⚡️ Magento DevSearch is a VS Code extension that allows y

Rafael Corrêa Gomes 12 Oct 18, 2022
Laravel-hours-helper - Creates a Collection of times with a given interval.

Laravel Hours Helper With laravel-hours-helper you can create a collection of dates and/of times with a specific interval (in minutes) for a specific

Label84 220 Dec 29, 2022
Increase "Death by 1000 needles" attack up to 100x times

Підсили свою атаку у 100 разів разом із db1000nX100 db1000nX100 це Linux контейнер для популярної програми db1000n, щo дозволяє значно підняти ефектив

null 62 Dec 31, 2022
Get mobile app version and other related data from Google Play Store, Apple App Store and Huawei AppGallery

Mobile App Version Get mobile app version and other related data from Google Play Store, Apple App Store and Huawei AppGallery. Installation Add to co

Omer Salaj 11 Mar 15, 2022
A faster drop in replacement for bin/magento cache:clean with file watcher

"You know, hope is a mistake. If you can't fix what's broken, you'll, uh... you'll go insane." - Max Rockatansky Magento 2 Cache Clean A faster drop i

mage2tv 460 Dec 26, 2022
Preload your sweet sweet code to opcache with a composer command, making your code faster to run.

Composer Preload Preload your sweet sweet code to opcache with a composer command, making your code run faster. Composer Preload is a composer plugin

Ayesh Karunaratne 197 Dec 6, 2022