Open alxgarci opened 1 month ago
I'm not very familiar with SQL or database queries, but from initial research, it looks like the slowdown for "Recent Series" and "Newest Authors" are both related to needing to verify the author and series have books after removing any permissions (from access control from limiting by tag or whether the item is explicit). Your logs show you as the root user which has access to all library items, so bookWhere
will be empty and just be checking that authors have books.
The authors query is simpler than the series query, so putting that here for reference. https://github.com/advplyr/audiobookshelf/blob/930bacd45d232b44a967c0744c9cfb82dcc592f4/server/utils/queries/libraryFilters.js#L324C1-L358C5
Maybe we can try adding the separate: true
to the include part of the query because the bookAuthor
has belongsToMany
associations? I'd also be curious if the query gets faster as more authors and series are no longer "new" after 60 days or if this is specifically related to the book count.
https://sequelize.org/docs/v7/querying/select-in-depth/#separate-eager-loading-queries
(customized shelves related to https://github.com/advplyr/audiobookshelf/issues/1241)
Well, I just tried that change locally, and turns out the HasMany
association does not exist for this query, so separate: true
does not work. I played with changing the attributes
that are used to see if removing the checks for tags
or explicit
would speed the query up at all and I didn't notice a change in loading time on a test library with 962 new authors and just under 6000 books.
For others having the same issue: Since it's hard for me to understand all the code and queries, i opted to comment every line inside those methods and return an empty array, which disables the section in the 'Home' tab.
So changing the getNewestAuthors
: https://github.com/advplyr/audiobookshelf/blob/930bacd45d232b44a967c0744c9cfb82dcc592f4/server/utils/queries/libraryFilters.js#L324C1-L358C5 commenting from line 325 to line 357, just leaving inside the method return { authors: [], count: 0 }
.
And changing getSeriesMostRecentlyAdded
:
https://github.com/advplyr/audiobookshelf/blob/930bacd45d232b44a967c0744c9cfb82dcc592f4/server/utils/queries/libraryFilters.js#L200C9-L200C35 commenting from line 201 to 313, just leaving inside the method return { series: [], count: 0 }
.
This cleanly disables both queries and makes everything load in under 2 seconds. For me this is a temporary fix, just enter in container's bash shell and install nano/vim.
What happened?
Everytime i open or switch between libraries, the home page takes too long to load. I've read another topics addressing similar issues but not this one. I had a 100k book library (epub, mobi, pdf,...) which i split in 20k libraries. Changing between libraries also triggers this. Problem occurs accessing the server through last Android app release, Chrome and Chrome for Android. If i change libraries while inside 'Library' tab, it takes 4 seconds, which is okay. Tested on docker versions 'edge' and 'v2.12.0'
What did you expect to happen?
To load faster, every other home item loads in less than 2 seconds. Or to optionally disable 'recent series' item.
Steps to reproduce the issue
Audiobookshelf version
v2.12.0
How are you running audiobookshelf?
Docker
What OS is your Audiobookshelf server hosted from?
Linux
If the issue is being seen in the UI, what browsers are you seeing the problem on?
Chrome
Logs
Additional Notes
Tried splitting the 100k book library in 20k smaller libraries, thinking 100k books were too many. Also tried android app and searching previous performance issues already solved.