fix(library): fix PlaylistDAO::removeHiddenTracks
performance
#11851
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes #11724
The query consists of an outer query and inner subquery. In the previous form, the inner query had a dependency on
p1.playlist_id
of the outer query. Which could change for each row of the outer select statement. This made the inner query aCORRELATED LIST SUBQUERY
, which caused the subquery to be re-evaluated for each row of the outer query. This dependency however is unnecessary because of theAND p1.playlist_id=:id
restriction in the outer query. So in theory,p1.playlist_id
never changes. Unfortunately, the SQLite was not able to make that deduction which lead to the dependency. Manually specifying that thep1.playlist_id
is constant for the entire subquery, removes the dependecy to the outer query, resulting in a plainLIST SUBQUERY
which can be evaluated once and then reused for all rows of the outer subquery. This results in reduced algorithmic complexity and thus drastically improved performance for large tables.