-
Notifications
You must be signed in to change notification settings - Fork 377
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
Scan for empty book series more efficiently #2103
Scan for empty book series more efficiently #2103
Conversation
btw there are other similar slow queries that run at startup, like the one that checks for books with no media, but the empty series scan was the most painfully slow one for me, so I started with this. |
Actually, doing a |
Thanks, I went and fixed the other 2 happening in that function. There are many more sql queries to optimize as well, unfortunately more complicated then those. |
Great! I think the next optimizations I will try to tackle are some of the
recommendations queries for the library home page. On my library the home
page takes 30+ seconds to load, so I'm sure there are some optimization
opportunities.
…On Sun, Sep 17, 2023, 1:54 PM advplyr ***@***.***> wrote:
Merged #2103 <#2103> into
master.
—
Reply to this email directly, view it on GitHub
<#2103 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AV3GPLFU3LP5GTFWTSA2NK3X25PRJANCNFSM6AAAAAA4ZKD5ME>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Your help with that would be great. I know that one of the main issues with the home page & library queries is they are not using the proper indexes. I've been using the EXPLAIN QUERY PLAN command to check the indexes |
@selfhost-alt You seem to be running into the same thing I am on the library home page if its that slow. Wrote about it here since it seemed most relevant but I suspect something is wrong with how cached images are getting served. |
I wonder if this could have also been fixed by just adding an index on seriesId (I suspect so, but it's hard to say. It's plausible that this change is faster than that regardless).
I used to work on Firefox, and the expert extension https://www.sqlite.org/src/dir?ci=trunk&name=ext/expert was a great help for optimizing the history/bookmarks (places) database. I believe the extension is now integrated in the SQLite CLI via the |
I've been trying to figure out why my server was starting so slowly after the Sqlite migration, and I found that the scan for empty book series seems to be the place where it spends the most time during startup.
I believe this slowness is due to the fact that it does a sub-query in the
WHERE
clause, which gets pretty inefficient when you have a largeseries
table (as I do).This is the original query that gets run before my change:
On my dev container, against a snapshot of my DB (10k
series
entries, 36kbookSeries
entries), this takes just under 10 minutes to complete.With this PR, the query changes to the following:
On my dev container against the same DB snapshot, this query takes about 300ms.