Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AlbumMappper::getForFile is not using an index #2444

Open
juliushaertl opened this issue Apr 22, 2024 · 0 comments
Open

AlbumMappper::getForFile is not using an index #2444

juliushaertl opened this issue Apr 22, 2024 · 0 comments
Labels
1. to develop Accepted and waiting to be taken care of performances Performances issues and optimisations

Comments

@juliushaertl
Copy link
Member

The following query does not seem ot use an index and do a full table scan on the albums table:

Screenshot 2024-04-22 at 10 17 01

$query = $this->connection->getQueryBuilder();
$query->select("a.album_id", "name", "user", "location", "created", "last_added_photo")
->from("photos_albums", "a")
->leftJoin("a", "photos_albums_files", "p", $query->expr()->eq("a.album_id", "p.album_id"))
->where($query->expr()->eq('file_id', $query->createNamedParameter($fileId, IQueryBuilder::PARAM_INT)));
$rows = $query->executeQuery()->fetchAll();
return array_map(function (array $row) {
return new AlbumInfo((int)$row['album_id'], $row['user'], $row['name'], $row['location'], (int)$row['created'], (int)$row['last_added_photo']);
}, $rows);

From a brief look it should be possible to refactor it to query the oc_photos_albums_files first to then get only the albums using an inner join

@juliushaertl juliushaertl added 1. to develop Accepted and waiting to be taken care of performances Performances issues and optimisations labels Apr 22, 2024
@juliushaertl juliushaertl changed the title AlumMappper::getForFile is not using an index AlbumMappper::getForFile is not using an index Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1. to develop Accepted and waiting to be taken care of performances Performances issues and optimisations
Projects
None yet
Development

No branches or pull requests

1 participant