Skip to content

Performance issue and scalability of popular search term cache #27559

Open
@mflott

Description

@mflott

Upon upgrading our site to 2.3, we saw a sudden increase in database CPU load. By looking at the processlist we saw a frequent query that took a lot of time:

SELECT DISTINCT COUNT(*) FROM search_queryASmain_table WHERE (main_table.store_id = 1) AND (num_results > 0)

We found that this is part of the 2.3.0 update where they added Popular Search Term Cache (This pull request) The larger the search_query table is, the longer the query takes to complete.

Preconditions (*)

  1. Magento Commerce 2.3.4
  2. ElasticSearch 6.7.0

Steps to reproduce (*)

  1. Make a query in the main search bar.

Expected result (*)

  1. The query is expected to finish within a reasonable amount of time.

Actual result (*)

  1. The query takes a long time to finish, depending on the size of the search_query table.

On our live site we have about 2,7 million search terms, so when doing queries this puts a lot of strain on the database and the queries are very slow. The main part that takes time is the num_results > 0 part - when we tested without this in our local testing environment we got a query duration of 0,7 sec., while if we included it it takes approx. 23 sec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: PerformanceArea: SearchComponent: SearchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for groomingReported on 2.3.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions