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

[Bug]: Performance of querying for Newest Authors on Homepage > 2mins for big E-Book Library #3525

Open
friral opened this issue Oct 15, 2024 · 4 comments
Labels
awaiting release Issue is resolved and will be in the next release bug Something isn't working

Comments

@friral
Copy link

friral commented Oct 15, 2024

What happened?

The Newest Author load time on the Homepage of is still (v2.15) very high for my 40K E-Book Library. Smaller libraries (1-2K audiobooks) are fine. The other similar 6 queries (see log) on the same page take only very few seconds or ms.
Tested on my desktop Firefox & the Android app with same results

What did you expect to happen?

  1. Load as fast as the other queries. For some reason the "Recently Added" query runs much quicker than "Newest Authors" although there are twice as many books/items than authors in the library
  2. For now, quickfix to make the library usable again: Maybe make the query for the newest authors disable-able in the settings

Steps to reproduce the issue

  1. Load 40k books into a book-library
  2. Navigate to Homepage of that library
  3. Watch the App freeze for a couple of minutes
  4. Check logs for the actual time

Audiobookshelf version

v 2.15.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?

None

Logs

2024-10-14 08:49:38.557
DEBUG
Loaded 8 of 8 items for "Continue Listening/Reading" in 0.72s

2024-10-14 08:49:43.263
DEBUG
Loaded 0 of 0 items for "Continue Series" in 4.71s

2024-10-14 08:49:43.672
DEBUG
Loaded 10 of 41478 items for "Recently Added" in 0.41s

2024-10-14 08:49:43.720
DEBUG
Loaded 5 of 2254 series for "Recent Series" in 0.05s

2024-10-14 08:49:47.160
DEBUG
Loaded 10 of 34816 items for "Discover" in 3.44s

2024-10-14 08:49:47.625
DEBUG
Loaded 4 of 4 items for "Listen/Read Again" in 0.47s

2024-10-14 08:52:07.970
DEBUG
Loaded 10 of 18309 authors for "Newest Authors" in 140.34s

2024-10-14 08:52:07.974
DEBUG
Loaded 6 personalized shelves in 150.13s

Additional Notes

No response

@friral friral added the bug Something isn't working label Oct 15, 2024
@nichwall
Copy link
Contributor

Same as #3237, but for authors instead of series. It is the same sort of query causing the slowdown. The backend data model likely needs to be changed to fix this.

Also discussed starting from #3259 (comment)

@friral
Copy link
Author

friral commented Oct 15, 2024

Don't forget about the possible quickfix to just disable the query/feature or introduce a setting for that to the user. I would certainly appreciate this low-effort solution until there is time for the 'big' solution to change the data model.

Right now the app is hardly usable to me whenever I (sometimes only by accident while browsing other libraries) touch the home screen of the books library

@advplyr
Copy link
Owner

advplyr commented Oct 16, 2024

We found that an index can solve this. If you want to resolve this before that release is ready you can run the following sql statement:

create index bookAuthors_bookId ON bookAuthors(authorId);

You'll probably want to remove that before migrating to 2.16.0 though to not have 2 indexes if we use a different name. If we use the same name it will be fine.

@friral
Copy link
Author

friral commented Oct 16, 2024

awesome! Good job!
Looking forward to the release

@advplyr advplyr added the awaiting release Issue is resolved and will be in the next release label Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting release Issue is resolved and will be in the next release bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants