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

Albums view very slow #279

Closed
gs11 opened this issue Feb 24, 2017 · 4 comments
Closed

Albums view very slow #279

gs11 opened this issue Feb 24, 2017 · 4 comments

Comments

@gs11
Copy link
Contributor

gs11 commented Feb 24, 2017

My collection contains 767 albums (10014 songs).
When browsing by album the first load is very slow causing MySQL to use 100% CPU and finally causing a timeout in the browser.
Subsequent browses are quicker but scrolling to the bottom to display the next n albums results in the same behavior but no timeout since it's quicker.

Running sonerezh (git master) on a nginx/debian machine with 2.4 GHz CPU / 4GB RAM.

@gs11
Copy link
Contributor Author

gs11 commented Feb 27, 2017

Ok, looked at the process list during load and the query is the culprit:

 SELECT `Song`.`id`, `Song`.`band`, `Song`.`album`, `Song`.`cover` FROM `sonerezh`.`songs` AS `Song` WHERE (`Song`.`id`, `Song`.`album`) IN (SELECT MIN(`subsong`.`id`), `subsong`.`album` FROM `sonerezh`.`songs` AS `subsong`   WHERE 1 = 1  GROUP BY `subsong`.`album`)  ORDER BY `Song`.`album` ASC  LIMIT 216, 36

Code is located in SongsController.php#L246

Why is a sub query (slow) used when the following statement yields the same result?

SELECT MIN(id), band, album, cover FROM songs GROUP BY album LIMIT 216, 36;

@gs11
Copy link
Contributor Author

gs11 commented Feb 27, 2017

Newly created pull request #283 fixes this.

@davebiffuk
Copy link

With this change, the album view for my collection (~700 albums, ~7000 mp3 files) loads in just a second or so, hosted on a tiny ARM-based server - thanks!

@gs11
Copy link
Contributor Author

gs11 commented Aug 17, 2018

Fix in PR #339

@gs11 gs11 closed this as completed Aug 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants