Skip to content

Commit 03091a9

Browse files
committed
ACP2E-3362: search_query table when of huge size, has large impact on load time frontend
1 parent d5fa6d6 commit 03091a9

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ public function isTopSearchResult(string $term, int $storeId, int $maxCountCache
171171
$select = $this->getSelect();
172172
$select->reset(\Magento\Framework\DB\Select::FROM);
173173
$select->reset(\Magento\Framework\DB\Select::COLUMNS);
174-
$select->distinct(true);
175174
$select->from(['main_table' => $this->getTable('search_query')], ['query_text']);
176175
$select->where('main_table.store_id IN (?)', $storeId);
177176
$select->where('main_table.num_results > 0');

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<column name="query_text"/>
3636
<column name="store_id"/>
3737
</constraint>
38-
<index referenceId="SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY" indexType="btree">
38+
<index referenceId="SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY" indexType="btree" disabled="true">
3939
<column name="query_text"/>
4040
<column name="store_id"/>
4141
<column name="popularity"/>
@@ -48,6 +48,12 @@
4848
<column name="num_results"/>
4949
<column name="popularity"/>
5050
</index>
51+
<index referenceId="SEARCH_QUERY_QUERY_TEXT_STORE_ID_NUM_RESULTS_POPULARITY" indexType="btree">
52+
<column name="query_text"/>
53+
<column name="store_id"/>
54+
<column name="num_results"/>
55+
<column name="popularity"/>
56+
</index>
5157
<index referenceId="SEARCH_QUERY_STORE_ID_POPULARITY" indexType="btree" disabled="true">
5258
<column name="store_id"/>
5359
<column name="popularity"/>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414
"updated_at": true
1515
},
1616
"index": {
17-
"SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": true,
17+
"SEARCH_QUERY_QUERY_TEXT_STORE_ID_NUM_RESULTS_POPULARITY": true,
1818
"SEARCH_QUERY_IS_PROCESSED": true,
1919
"SEARCH_QUERY_SYNONYM_FOR": true,
20+
"SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": false,
2021
"SEARCH_QUERY_STORE_ID_NUM_RESULTS_POPULARITY": true,
2122
"SEARCH_QUERY_STORE_ID": false,
2223
"SEARCH_QUERY_STORE_ID_POPULARITY": false

0 commit comments

Comments
 (0)