Skip to content

Fulltext search index: slow query in resetSearchResults() #566

Closed
@arhu32

Description

@arhu32

In Magento/CatalogSearch/Model/Resource/Fulltext.php, function resetSearchResults() there are some queries that set the whole column "is_processed" in the table "catalogsearch_query" to 0, e.g.:

$adapter->update($this->getTable('catalogsearch_query'),
    array('is_processed' => 0));

This query is very slow because it possibly needs to update lots of rows every time resetSearchResults() is called. On our server (mage181, multi-store setup, no SSD) with ~40.000 rows in the table, the query took 0.5 seconds and was called regularly during product updates etc.

Fix:

  1. Only update rows that are not already 0:

    $adapter->update($this->getTable('catalogsearch/search_query'),
        array('is_processed' => 0), array('is_processed != 0'));
  2. Add an index to the "is_processed" column in the "catalogsearch_query" table.

This will speed up the query considerably. AFAIK this issue affects all Magento versions, including 1.8.1.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions