Skip to content

Comments

Query for image query result metadata separately#6370

Merged
WithoutPants merged 4 commits intostashapp:developfrom
WithoutPants:image-performance
Dec 7, 2025
Merged

Query for image query result metadata separately#6370
WithoutPants merged 4 commits intostashapp:developfrom
WithoutPants:image-performance

Conversation

@WithoutPants
Copy link
Collaborator

Makes the query for total megapixels and filesize separate from the main image query so that the former doesn't cause delays in returning the images themselves.

Shows (...) in the metadata info section while the metadata info query is running:

image

Haven't yet noticed a huge difference on my production system of >300k images. Going to try a larger db when I migrate it.

Resolves #6319

@WithoutPants WithoutPants added this to the Version 0.30.0 milestone Dec 3, 2025
@WithoutPants WithoutPants added improvement Something needed tweaking. needs testing Pull requests that require testing labels Dec 3, 2025
@z9gccs4zkw-ship-it
Copy link

Much Thanks! will try on my machine once pushed. for reference my system has 4.7TB of images (7,7M)

@WithoutPants
Copy link
Collaborator Author

I've done a bit of testing on a system with 32M images.

When getting everything at once (legacy behaviour), the full query for a single image sorted by path took 29s for the aggregate query (count, filesize, megapixels), followed by 42s to get the image ids, for a total wait of 71s.

When splitting it into two separate parallel queries, the query for the filesize and megapixels took 24s, then the query for the content took 5s for the count, and 42s to get the image ids. This means a total wait of 47s for the items to return, and 24s for the other info to populate. We could possibly shave some further time off that if we took out the count from the item query.

Performance for larger systems is still nowhere near acceptable, but this should improve things a little. Further work needs to be done at the schema level to determine what indexes are worth adding and what we can do at the sorting level to improve performance.

Related #6378

@sleetx
Copy link

sleetx commented Dec 5, 2025

Is there a justification for calculating "total megapixels" at all? I find that metric to be completely irrelevant. Megapixels is useful when reviewing the properties of an individual image, not a whole collection.

Maybe "total megapixels" is best placed on the Stats page. But I don't think it's worth calculating every time you open the Images tab, especially given how much it taxes processing time.

@WithoutPants
Copy link
Collaborator Author

Is there a justification for calculating "total megapixels" at all? I find that metric to be completely irrelevant. Megapixels is useful when reviewing the properties of an individual image, not a whole collection.

Related feature request and PR: #1775

In my testing, adding megapixels added around 25% to the overhead when calculating total file size (which I think does belong). I am fairly ambivalent as to whether to keep it around - I think the utility is marginal at best.

@WithoutPants WithoutPants merged commit eb9d070 into stashapp:develop Dec 7, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Something needed tweaking. needs testing Pull requests that require testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make "Megapixels" and "Filesize" in the GraphQL query in Images page optional or remove altogether

3 participants