Skip to content

Commit

Permalink
Possibly expensive SQL Query on determining files to process #144
Browse files Browse the repository at this point in the history
Cast fileid to objectid and use the index
  • Loading branch information
Philip Stadermann committed Oct 16, 2024
1 parent e5eceab commit 2550edb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Db/DbFileMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getFileIdsWithoutTags(array $excludedTagIds, int $limit, int $of

$qb->select('f.fileid')
->from($this->getTableName(), 'f')
->leftJoin('f', 'systemtag_object_mapping', 'o', $qb->expr()->eq('f.fileid', $qb->createFunction($this->getPlatformSpecificCast())))
->leftJoin('f', 'systemtag_object_mapping', 'o', $qb->expr()->eq('o.objectid', $qb->createFunction('CAST(f.fileid AS VARCHAR(64))')))
->leftJoin('f', 'mimetypes', 'm', $qb->expr()->eq('f.mimetype', 'm.id'))
->where($qb->expr()->notIn('o.systemtagid', $qb->createNamedParameter($excludedTagIds, IQueryBuilder::PARAM_INT_ARRAY)))
->orWhere($qb->expr()->isNull('o.systemtagid'))
Expand Down Expand Up @@ -65,7 +65,7 @@ public function getFileIdsWithTags(array $includedTagIds, int $limit, int $offse

$qb->select('f.fileid')
->from($this->getTableName(), 'f')
->leftJoin('f', 'systemtag_object_mapping', 'o', $qb->expr()->eq('f.fileid', $qb->createFunction($this->getPlatformSpecificCast())))
->leftJoin('f', 'systemtag_object_mapping', 'o', $qb->expr()->eq('o.objectid', $qb->createFunction('CAST(f.fileid AS VARCHAR(64))')))
->leftJoin('f', 'mimetypes', 'm', $qb->expr()->eq('f.mimetype', 'm.id'))
->where($qb->expr()->in('o.systemtagid', $qb->createNamedParameter($includedTagIds, IQueryBuilder::PARAM_INT_ARRAY)))
->andWhere($qb->expr()->notLike('m.mimetype', $qb->createNamedParameter('%unix-directory%')))
Expand Down

0 comments on commit 2550edb

Please sign in to comment.