Merge pull request #54777 from nextcloud/perf/carddav/ungreedify-search

perf(carddav): ungreedify search result aggregation
This commit is contained in:
Andy Scherzinger 2025-09-02 14:59:02 +02:00 committed by GitHub
commit 38327e4493
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1238,7 +1238,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
return (int)$match['cardid'];
}, $matches);
$cards = [];
$cardResults = [];
$query = $this->db->getQueryBuilder();
$query->select('c.addressbookid', 'c.carddata', 'c.uri')
->from($this->dbCardsTable, 'c')
@ -1247,10 +1247,11 @@ class CardDavBackend implements BackendInterface, SyncSupport {
foreach (array_chunk($matches, 1000) as $matchesChunk) {
$query->setParameter('matches', $matchesChunk, IQueryBuilder::PARAM_INT_ARRAY);
$result = $query->executeQuery();
$cards = array_merge($cards, $result->fetchAll());
$cardResults[] = $result->fetchAll();
$result->closeCursor();
}
$cards = array_merge(...$cardResults);
return array_map(function ($array) {
$array['addressbookid'] = (int)$array['addressbookid'];
$modified = false;