Increase performance by selecting on indexed column

This commit is contained in:
Maximilian Ruta 2020-04-19 17:14:34 +02:00
parent 045577176e
commit a3e1b73830

View file

@ -93,11 +93,15 @@ class RuleManager {
public function getRulesForFilesByPath(IUser $user, int $storageId, array $filePaths): array {
$userMappings = $this->userMappingManager->getMappingsForUser($user);
$hashes = array_map(function (string $path) {
return md5($path);
}, $filePaths);
$query = $this->connection->getQueryBuilder();
$query->select(['f.fileid', 'mapping_type', 'mapping_id', 'mask', 'a.permissions', 'path'])
->from('group_folders_acl', 'a')
->innerJoin('a', 'filecache', 'f', $query->expr()->eq('f.fileid', 'a.fileid'))
->where($query->expr()->in('path', $query->createNamedParameter($filePaths, IQueryBuilder::PARAM_STR_ARRAY)))
->where($query->expr()->in('path_hash', $query->createNamedParameter($hashes, IQueryBuilder::PARAM_STR_ARRAY)))
->andWhere($query->expr()->eq('storage', $query->createNamedParameter($storageId, IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->orX(...array_map(function (IUserMapping $userMapping) use ($query) {
return $query->expr()->andX(