SQL performance improvements#6378
Merged
WithoutPants merged 4 commits intostashapp:developfrom Dec 7, 2025
Merged
Conversation
Using queryFunc meant that the performance logging was inaccurate due to the query actually being executed during the call to Scan.
Should provide some marginal improvement on systems with a lot of items.
This means that long queries can be cancelled by navigating to another page. Previously the query would continue to run, impacting on future queries.
Contributor
I wonder if this is what #2272 was about |
Collaborator
Author
I think almost certainly. |
|
This pull request has been mentioned on Stash. There might be relevant details there: |
WithoutPants
added a commit
to WithoutPants/stash
that referenced
this pull request
Dec 15, 2025
This reverts commit 0fd7a2a.
WithoutPants
added a commit
to WithoutPants/stash
that referenced
this pull request
Dec 15, 2025
This reverts commit 0fd7a2a.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I fell down a bit of a rabbit hole while exploring for performance improvements for #6370.
I made the following improvements:
queryStructto usetx.Getinstead of queryFuncargsto the args list even if the join was not addedThe last item was the most important one. This fixes what I believe is a pretty nasty latent bug, where queries would not be canceled when the applicable http request was canceled.
An an example, on a database with 32m images - where each image request takes around a minute - I flicked through pages, changed the sort order and direction, and the page sizes all before any results came back. I had to force kill the process because it was cooking my server 😬
A nice side-effect of this is that you can now kill the stash instance while a query is running if you cancel the request via navigating to another page in the UI (assuming the request came from the UI). Previously it would hang until the queries were complete - unless you
kill -9it.