mirror of
https://github.com/photoprism/photoprism.git
synced 2026-03-02 22:57:18 -05:00
Photos don't load #98
Labels
No labels
ai
android
api
auth
awesome
bug
bug
ci
cli
config
database
declined
deprecated
docker
docs 📚
documents
duplicate
easy
enhancement
enhancement
enhancement
epic
faces
feedback wanted
frontend
hacktoberfest
help wanted
idea
in-progress
incomplete
index
invalid
ios
labels
live
live
low-priority
macos
member-feature
metadata
mobile
nas
needs-analysis
no-coding-required
no-coding-required
observability
performance
places
please-test
plus-feature
priority
pro-feature
question
raspberry-pi
raw
released
released
released
research
resolved
security
sharing
tested
tests
third-party-issue
thumbnails
upgrade
upstream-issue
ux
vector
video
waiting
won't fix
won't fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/photoprism#98
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @p80n on GitHub (Jun 27, 2019).
Originally assigned to: @lastzero on GitHub.
Tried to update to a more recent docker image, but if I use an image more recent than
20190607, the initial gallery page has the nav bar and a progress bar, but photos never load.I wonder if it could be related to the addition of
SQL_CALC_FOUND_ROWSto this query:github.com/photoprism/photoprism@5f63f2999c/internal/photoprism/search.go (L51)While the page is attempting to load, I see this query repeated three times in MySQL's process list:
For my install, with ~6,800 photos, this query is taking about 5 minutes to execute.
On a side note, a bit of googling seems to indicate
SQL_CALC_FOUND_ROWSmay not be optimal. Apparently it's been deprecated in MySQL.https://dev.mysql.com/doc/refman/8.0/en/information-functions.html
Let me know if I can provide other info. Thanks!
@p80n commented on GitHub (Jun 27, 2019):
Actually, just manually ran that query without
SQL_CALC_FOUND_ROWS, still takes a bit on my host. So maybe it's more related to the joins involved.hth
@lastzero commented on GitHub (Jun 27, 2019):
You are 100% right: The query is not optimized and we can remove SQL_CALC_FOUND_ROWS as we don't display the total number of photos in our app at the moment. We tried to get this to work with GORM just in case as running a second query is not always reliable and may also be slower.
Is the search in the app also slow or just if you run the query manually? Any other issues you noticed?
Note that this is a preview and database tables are still changing a lot - you should be prepared to re-build your index after an upgrade. This may also lead to performance improvements (maybe not in this case).
@lastzero commented on GitHub (Jun 27, 2019):
Also using MySQL instead of the built-in TiDB might be faster (or slower). Would be amazing if you can test the difference for us! 👍
@p80n commented on GitHub (Jun 28, 2019):
It looks like switching to TiDB fixes the issue. Same query runs in ~1.5 seconds!
I'm going to update MySQL and do a bit more testing (just cause I'm kind of shocked it's that large of a difference). I'll post an update if I run across anything interesting.
@lastzero commented on GitHub (Jul 3, 2019):
Removed
SQL_CALC_FOUND_ROWSand added an index tophoto_lat,photo_longandtaken_at. Let us know if that helps. If yes, please close the ticket 👍Also updated the docs at https://docs.photoprism.org/en/latest/setup/ - we changed the port and path in the Docker image, so this was outdated. How did you run / install PhotoPrism? Any issues?
@p80n commented on GitHub (Jul 3, 2019):
Updated to the latest and re-tested.
Query was actually still taking about the same time to run. I did some digging and narrowed it down to the join on
photos_labels. Did some more digging and saw that whilephoto_idis indexed as part of the primary key on that tablePRIMARY KEY (`label_id`,`photo_id`),I don't think the actual join
LEFT JOIN photos_labels ON photos_labels.photo_id = photos.idis able to utilize the index, since
label_idis not included.So I added another index
KEY `idx_photos_id` (`photo_id`)and now that query runs in about 0.5 seconds :)
I also tried reversing the order in the primary key. That also gets the query working, but I wasn't sure if there could be impacts to other bits of the code (i.e., that might query that table by just
label_id).For your second question, I actually run this in a kubernetes cluster. I have several small machines, so for me it's helpful to be able to run Photoprism on one, database on another. But I've just been translating your docker-compose to kube yaml no prob.
Thanks for the heads-up though - port change would've had me scratching my head for a bit otherwise.
@lastzero commented on GitHub (Jul 3, 2019):
Thank you, that was very helpful! Indeed, we need to be able to query the table both ways. I've just updated the model accordingly. Will be available as Docker image
when we merge into master next timein about one hour. Build is running on TravisCI:https://travis-ci.org/photoprism/photoprism/builds/553887037
@lastzero commented on GitHub (Jul 3, 2019):
@p80n Would be amazing if you share your kube yaml and any other advice for running this on Kubernetes... for example in our Wiki: Simply create a new page "Kubernetes" and add a link to it directly under Distribution on the main page
@p80n commented on GitHub (Jul 3, 2019):
Tested it out on a fresh DB - works great 👍 Thanks!
I'll take a look at making the kube stuff I have generic and see if I can get something posted.