The issue is the amount of data processed, you can improve the queries limits to return just the top results or you can apply these changed below via path or module to eliminate the counting of search terms.
Index: vendor/magento/module-search/Model/Query.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- a/vendor/magento/module-search/Model/Query.php (date 1589899020381)
+++ b/vendor/magento/module-search/Model/Query.php (date 1589899020381)
@@ -243,7 +243,8 @@
*/
public function saveIncrementalPopularity()
{
- $this->getResource()->saveIncrementalPopularity($this);
+ // Removed to save MySQL resources
+ // $this->getResource()->saveIncrementalPopularity($this);
return $this;
}
@@ -259,7 +260,9 @@
public function saveNumResults($numResults)
{
$this->setNumResults($numResults);
- $this->getResource()->saveNumResults($this);
+
+ // Removed to save MySQL resources
+ // $this->getResource()->saveNumResults($this);
return $this;
}
Index: vendor/magento/module-search/Model/PopularSearchTerms.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- a/vendor/magento/module-search/Model/PopularSearchTerms.php (date 1589899721241)
+++ b/vendor/magento/module-search/Model/PopularSearchTerms.php (date 1589899721241)
@@ -48,13 +48,9 @@
*/
public function isCacheable(string $term, int $storeId)
{
- $terms = $this->queryCollection
- ->setPopularQueryFilter($storeId)
- ->setPageSize($this->getMaxCountCacheableSearchTerms($storeId))
- ->load()
- ->getColumnValues('query_text');
-
- return in_array($term, $terms);
+ // Removed cacheable checks to save MySQL resources as there can be
+ // around 20k different terms used per day
+ return false;
}
/**