/
Front-End search performance improvements [5.2.2-B2]
Front-End search performance improvements [5.2.2-B2]
In-Portal supports search across whole catalog on Front-End. Here is what happens internally for each catalog item (category, product, link, etc.):
- drop temporary search table if it exists
- create temporary search table with results OR append results to it (when catalog items of different types found)
During regular search page load fact, that instead of truncating a table it's being dropped and recreated isn't a bid deal. However when based on search page developers attempt to create AJAX auto-suggestion template, where on every key press same drop/create table code happens the racing condition might happen, when:
- one AJAX requests checks for table existence
- another AJAX requests immediately drops that table
Solution
- in the "OnSimpleSearch" events:
- use "MEMORY" engine, when creating temp search table (improves speed)
- instead of dropping temp search table clean it using "TRUNCATE TABLE" database query
- in the "\kSearchHelper::ensureEmptySearchTable" method:
- create temp search table in memory and only, when it's missing
- clean temp search table using "TRUNCATE TABLE" database query