Commit d673b7f6 authored by Stefan Froemken's avatar Stefan Froemken Committed by Christian Kuhn
Browse files

[TASK] Use ORDER BY uid DESC in LiveSearch

Sorting query results by text columns may require
a filesort on harddisk which is slow. To boost up
the search results of LiveSearch we have added
an ORDER BY uid DESC to always show the newest
created records first. Column "uid" exists in
all TCA tables and as it is PRIMARY INDEX
sorting will happen in memory.

Resolves: #96365
Releases: main, 11.5
Change-Id: Icbf6e8c7717a495aaee995ff09cf2cd882173e65
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/72917

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 6bda1ea5
......@@ -200,11 +200,7 @@ class LiveSearch
$queryBuilder->andWhere($this->userPermissions);
}
$orderBy = $GLOBALS['TCA'][$tableName]['ctrl']['sortby'] ?? $GLOBALS['TCA'][$tableName]['ctrl']['default_sortby'] ?? '';
foreach (QueryHelper::parseOrderBy((string)$orderBy) as $orderPair) {
[$fieldName, $order] = $orderPair;
$queryBuilder->addOrderBy($fieldName, $order);
}
$queryBuilder->addOrderBy('uid', 'DESC');
$getRecordArray = $this->getRecordArray($queryBuilder, $tableName);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment