Skip to content

Commit 4eb7aae

Browse files
committed
ACP2E-2101: Admin dashboard slowness
1 parent 0a834cc commit 4eb7aae

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

app/code/Magento/Search/Model/ResourceModel/Query/Collection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ public function setPopularQueryFilter($storeIds = null)
150150

151151
$storeIds = $storeIds ?: $this->_storeManager->getStore()->getId();
152152
$this->addStoreFilter($storeIds);
153-
$this->getSelect()->where('num_results > 0');
153+
$this->getSelect()->where('main_table.num_results > 0');
154154

155-
$this->getSelect()->order(['popularity desc']);
155+
$this->getSelect()->order(['main_table.popularity desc']);
156156

157157
return $this;
158158
}
@@ -174,8 +174,8 @@ public function isTopSearchResult(string $term, int $storeId, int $maxCountCache
174174
$select->distinct(true);
175175
$select->from(['main_table' => $this->getTable('search_query')], ['query_text']);
176176
$select->where('main_table.store_id IN (?)', $storeId);
177-
$select->where('num_results > 0');
178-
$select->order(['popularity desc']);
177+
$select->where('main_table.num_results > 0');
178+
$select->order(['main_table.popularity desc']);
179179

180180
$select->limit($maxCountCacheableSearchTerms);
181181

@@ -208,7 +208,7 @@ public function setRecentQueryFilter()
208208
public function addStoreFilter($storeIds)
209209
{
210210
$condition = is_array($storeIds) ? 'main_table.store_id IN (?)' : 'main_table.store_id = ?';
211-
$this->getSelect()->where($condition, $storeIds);
211+
$this->getSelect()->where($condition, $storeIds, \Zend_Db::INT_TYPE);
212212

213213
return $this;
214214
}

app/code/Magento/Search/etc/db_schema.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,15 @@
4646
<index referenceId="SEARCH_QUERY_IS_PROCESSED" indexType="btree">
4747
<column name="is_processed"/>
4848
</index>
49-
<index referenceId="SEARCH_QUERY_STORE_ID_POPULARITY" indexType="btree">
49+
<index referenceId="SEARCH_QUERY_STORE_ID_NUM_RESULTS_POPULARITY" indexType="btree">
50+
<column name="store_id"/>
51+
<column name="num_results"/>
52+
<column name="popularity"/>
53+
</index>
54+
<index referenceId="SEARCH_QUERY_STORE_ID" indexType="btree" disabled="true">
55+
<column name="store_id"/>
56+
</index>
57+
<index referenceId="SEARCH_QUERY_STORE_ID_POPULARITY" indexType="btree" disabled="true">
5058
<column name="store_id"/>
5159
<column name="popularity"/>
5260
</index>

app/code/Magento/Search/etc/db_schema_whitelist.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
},
1616
"index": {
1717
"SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": true,
18-
"SEARCH_QUERY_STORE_ID": true,
1918
"SEARCH_QUERY_IS_PROCESSED": true,
2019
"SEARCH_QUERY_SYNONYM_FOR": true,
21-
"SEARCH_QUERY_STORE_ID_POPULARITY": true
20+
"SEARCH_QUERY_STORE_ID_NUM_RESULTS_POPULARITY": true,
21+
"SEARCH_QUERY_STORE_ID": false,
22+
"SEARCH_QUERY_STORE_ID_POPULARITY": false
2223
},
2324
"constraint": {
2425
"PRIMARY": true,

0 commit comments

Comments
 (0)