mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
divide ids into chunks of 1k
This commit is contained in:
parent
e8bf576184
commit
27511d9187
1 changed files with 18 additions and 9 deletions
|
|
@ -239,16 +239,25 @@ class Shared_Cache extends Cache {
|
|||
}
|
||||
|
||||
}
|
||||
$placeholders = join(',', array_fill(0, count($ids), '?'));
|
||||
|
||||
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag`
|
||||
FROM `*PREFIX*filecache` WHERE `name` LIKE ? AND `fileid` IN (' . $placeholders . ')';
|
||||
$result = \OC_DB::executeAudited($sql, array_merge(array($pattern), $ids));
|
||||
|
||||
$files = array();
|
||||
while ($row = $result->fetchRow()) {
|
||||
$row['mimetype'] = $this->getMimetype($row['mimetype']);
|
||||
$row['mimepart'] = $this->getMimetype($row['mimepart']);
|
||||
$files[] = $row;
|
||||
|
||||
// divide into 1k chunks
|
||||
$chunks = array_chunk($ids, 1000);
|
||||
|
||||
foreach ($chunks as $chunk) {
|
||||
$placeholders = join(',', array_fill(0, count($chunk), '?'));
|
||||
|
||||
$sql = 'SELECT `fileid`, `storage`, `path`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted`, `unencrypted_size`, `etag`
|
||||
FROM `*PREFIX*filecache` WHERE `name` LIKE ? AND `fileid` IN (' . $placeholders . ')';
|
||||
|
||||
$result = \OC_DB::executeAudited($sql, array_merge(array($pattern), $chunk));
|
||||
|
||||
while ($row = $result->fetchRow()) {
|
||||
$row['mimetype'] = $this->getMimetype($row['mimetype']);
|
||||
$row['mimepart'] = $this->getMimetype($row['mimepart']);
|
||||
$files[] = $row;
|
||||
}
|
||||
}
|
||||
return $files;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue