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

[7.13.3] Some database queries can be very slow #7954

Closed
kozlovsky opened this issue Apr 4, 2024 · 1 comment · Fixed by #7955
Closed

[7.13.3] Some database queries can be very slow #7954

kozlovsky opened this issue Apr 4, 2024 · 1 comment · Fixed by #7955
Assignees

Comments

@kozlovsky
Copy link
Contributor

I found a few queries to the TorrentState that can be pretty slow. On my (pretty fast) machine with SSD, such a query takes 4 seconds to execute after a cold start. On a machine with HDD, it can be slower in order of magnitude. This can be the reason for some CoreConnectTimeoutError errors.

The reason for the slowness is that to be fast, the query should use a partial index idx_torrentstate__last_check__partial, and for that, the query should contain exactly the following condition for the TorrentState table: has_data = 1. In that case, the SQLite query optimizer can use the index when constructing the query plan.

Several queries to the TorrentState table do not include this condition, so they do not use the index and execute slowly.

After the fix, the same query executes in 0.04 seconds, eliminating the problem.

@kozlovsky
Copy link
Contributor Author

Fixed in #7955

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant